28 lines
554 B
Plaintext
28 lines
554 B
Plaintext
' FB 1.05.0 Win64
|
|
|
|
Function digitalRoot(n As UInteger, ByRef ap As Integer, base_ As Integer = 10) As Integer
|
|
Dim dr As Integer
|
|
ap = 0
|
|
Do
|
|
dr = 0
|
|
While n > 0
|
|
dr += n Mod base_
|
|
n = n \ base_
|
|
Wend
|
|
ap += 1
|
|
n = dr
|
|
Loop until dr < base_
|
|
Return dr
|
|
End Function
|
|
|
|
Dim As Integer dr, ap
|
|
Dim a(3) As UInteger = {627615, 39390, 588225, 393900588225}
|
|
For i As Integer = 0 To 3
|
|
ap = 0
|
|
dr = digitalRoot(a(i), ap)
|
|
Print a(i), "Additive Persistence ="; ap, "Digital root ="; dr
|
|
Print
|
|
Next
|
|
Print "Press any key to quit"
|
|
Sleep
|