Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
35
Task/Digital-root/FutureBasic/digital-root.basic
Normal file
35
Task/Digital-root/FutureBasic/digital-root.basic
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
//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
|
||||
Loading…
Add table
Add a link
Reference in a new issue