Data update
This commit is contained in:
parent
61b93a2cd1
commit
5af6d93694
858 changed files with 20572 additions and 2082 deletions
24
Task/Digital-root/BASIC256/digital-root.basic
Normal file
24
Task/Digital-root/BASIC256/digital-root.basic
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
global dr
|
||||
global ap
|
||||
|
||||
dim a = {627615, 39390, 588225}
|
||||
|
||||
for i = 0 to a[?]-1
|
||||
dr = digitalRoot(a[i])
|
||||
print a[i], "Additive Persistence = "; ap, "Digital root = "; dr
|
||||
next i
|
||||
end
|
||||
|
||||
function digitalRoot(n)
|
||||
ap = 0
|
||||
do
|
||||
dr = 0
|
||||
while n > 0
|
||||
dr += n mod 10
|
||||
n = n \ 10
|
||||
end while
|
||||
ap += 1
|
||||
n = dr
|
||||
until dr < 10
|
||||
return dr
|
||||
end function
|
||||
22
Task/Digital-root/True-BASIC/digital-root.basic
Normal file
22
Task/Digital-root/True-BASIC/digital-root.basic
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
SUB digitalroot (what)
|
||||
LET dr = ABS(what)
|
||||
IF dr > 10 THEN
|
||||
LET ap = 0
|
||||
DO
|
||||
LET ap = ap + 1
|
||||
DO WHILE dr <> 0
|
||||
LET t = t + REMAINDER(dr, 10)
|
||||
LET dr = IP(dr / 10)
|
||||
LOOP
|
||||
LET dr = t
|
||||
LET t = 0
|
||||
LOOP WHILE dr > 9
|
||||
END IF
|
||||
PRINT what, "Additive persistance ="; ap, "Digital root ="; dr
|
||||
END SUB
|
||||
|
||||
CALL digitalroot (627615)
|
||||
CALL digitalroot (39390)
|
||||
CALL digitalroot (588225)
|
||||
CALL digitalroot (393900588225)
|
||||
END
|
||||
21
Task/Digital-root/Yabasic/digital-root.basic
Normal file
21
Task/Digital-root/Yabasic/digital-root.basic
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
dim a(2)
|
||||
a(0) = 627615 : a(1) = 39390 : a(2) = 588225
|
||||
for i = 0 to arraysize(a(),1)
|
||||
dr = digitalRoot(a(i))
|
||||
print a(i), "\tAdditive persistence = ", ap, "\tDigital root = ", dr
|
||||
next i
|
||||
end
|
||||
|
||||
sub digitalRoot(n)
|
||||
ap = 0
|
||||
repeat
|
||||
dr = 0
|
||||
while n > 0
|
||||
dr = dr + mod(n, 10)
|
||||
n = int(n / 10)
|
||||
wend
|
||||
ap = ap + 1
|
||||
n = dr
|
||||
until dr < 10
|
||||
return dr
|
||||
end sub
|
||||
Loading…
Add table
Add a link
Reference in a new issue