langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
24
Task/Digital-root/BASIC/digital-root.basic
Normal file
24
Task/Digital-root/BASIC/digital-root.basic
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
DECLARE SUB digitalRoot (what AS LONG)
|
||||
|
||||
'test inputs:
|
||||
digitalRoot 627615
|
||||
digitalRoot 39390
|
||||
digitalRoot 588225
|
||||
|
||||
SUB digitalRoot (what AS LONG)
|
||||
DIM w AS LONG, t AS LONG, c AS INTEGER
|
||||
|
||||
w = ABS(what)
|
||||
IF w > 10 THEN
|
||||
DO
|
||||
c = c + 1
|
||||
WHILE w
|
||||
t = t + (w MOD (10))
|
||||
w = w \ 10
|
||||
WEND
|
||||
w = t
|
||||
t = 0
|
||||
LOOP WHILE w > 9
|
||||
END IF
|
||||
PRINT what; ": additive persistance "; c; ", digital root "; w
|
||||
END SUB
|
||||
Loading…
Add table
Add a link
Reference in a new issue