Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
27
Task/Digital-root/FreeBASIC/digital-root.freebasic
Normal file
27
Task/Digital-root/FreeBASIC/digital-root.freebasic
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
' 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue