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
25
Task/Digital-root/Sidef/digital-root.sidef
Normal file
25
Task/Digital-root/Sidef/digital-root.sidef
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
func digroot (r, base = 10) {
|
||||
var root = r.base(base)
|
||||
var persistence = 0
|
||||
while (root.len > 1) {
|
||||
root = root.chars.map{|n| Number(n, 36) }.sum(0).base(base)
|
||||
++persistence
|
||||
}
|
||||
return(persistence, root)
|
||||
}
|
||||
|
||||
var nums = [5, 627615, 39390, 588225, 393900588225]
|
||||
var bases = [2, 3, 8, 10, 16, 36]
|
||||
var fmt = "%25s(%2s): persistance = %s, root = %2s\n"
|
||||
|
||||
nums << (550777011503 *
|
||||
105564897893993412813307040538786690718089963180462913406682192479)
|
||||
|
||||
bases.each { |b|
|
||||
nums.each { |n|
|
||||
var x = n.base(b)
|
||||
x = 'BIG' if (x.len > 25)
|
||||
fmt.printf(x, b, digroot(n, b))
|
||||
}
|
||||
print "\n"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue