36 lines
546 B
Plaintext
36 lines
546 B
Plaintext
//Digital Root task
|
|
//https://rosettacode.org/wiki/Digital_root
|
|
// Translated from Yabasic to FutureBASIC
|
|
|
|
begin globals
|
|
long ap = 0
|
|
long dr = 0
|
|
end globals
|
|
|
|
local fn digitalRoot(n as long)
|
|
ap = 0
|
|
|
|
do
|
|
dr = 0
|
|
while n > 0
|
|
dr = dr + n mod(10)
|
|
n = int(n / 10)
|
|
wend
|
|
|
|
ap = ap + 1
|
|
n = dr
|
|
until dr < 10
|
|
|
|
end fn = dr
|
|
|
|
|
|
long a(2)
|
|
a(0) = 627615 : a(1) = 39390 : a(2) = 588225
|
|
short i
|
|
for i = 0 to 2
|
|
dr = fn digitalRoot(a(i))
|
|
print a(i), "Additive persistence = ", ap, "Digital root = ", dr
|
|
next i
|
|
|
|
handleevents
|