testNumbers = [627615, 39390, 588225, 393900588225, 45, 9991] pad = function(n, width) return (n + " " * width)[:width] end function getDigitalRoot = function(n) persistance = 0 while floor(log(n)) > 0 sum = 0 while n > 0 sum += n % 10 n = floor(n / 10) end while n = sum persistance += 1 end while return [n, persistance] end function for num in testNumbers digRoot = getDigitalRoot(num) print pad(num, 12), "" print " has a digital root ", "" print digRoot[0], "" print " and additive persistance ","" print digRoot[1] end for