Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
29
Task/Digital-root/BBC-BASIC/digital-root.basic
Normal file
29
Task/Digital-root/BBC-BASIC/digital-root.basic
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
*FLOAT64
|
||||
PRINT "Digital root of 627615 is "; FNdigitalroot(627615, 10, p) ;
|
||||
PRINT " (additive persistence " ; p ")"
|
||||
PRINT "Digital root of 39390 is "; FNdigitalroot(39390, 10, p) ;
|
||||
PRINT " (additive persistence " ; p ")"
|
||||
PRINT "Digital root of 588225 is "; FNdigitalroot(588225, 10, p) ;
|
||||
PRINT " (additive persistence " ; p ")"
|
||||
PRINT "Digital root of 393900588225 is "; FNdigitalroot(393900588225, 10, p) ;
|
||||
PRINT " (additive persistence " ; p ")"
|
||||
PRINT "Digital root of 9992 is "; FNdigitalroot(9992, 10, p) ;
|
||||
PRINT " (additive persistence " ; p ")"
|
||||
END
|
||||
|
||||
DEF FNdigitalroot(n, b, RETURN c)
|
||||
c = 0
|
||||
WHILE n >= b
|
||||
c += 1
|
||||
n = FNdigitsum(n, b)
|
||||
ENDWHILE
|
||||
= n
|
||||
|
||||
DEF FNdigitsum(n, b)
|
||||
LOCAL q, s
|
||||
WHILE n <> 0
|
||||
q = INT(n / b)
|
||||
s += n - q * b
|
||||
n = q
|
||||
ENDWHILE
|
||||
= s
|
||||
Loading…
Add table
Add a link
Reference in a new issue