function AdditivePersistence(num) {
var sum, loop = 0;
var val1 = num.toString(10).split("").map(function(t){return parseInt(t)});
while (val1.length > 1) {
sum = 0;
val1.forEach( function(number) {
sum = sum + number;
});
val1 = sum.toString(10).split("").map(function(t){return parseInt(t)});
loop++;
}
return loop;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter