Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,19 @@
require('ntheory')
var kap = Hash()
15.times { |n|
var np = (10**n - 1)
%S<ntheory>.fordivisors({ |d|
var dp = np//d
if (gcd(d, dp) == 1) {
kap{ dp == 1 ? d : d.invmod(dp)*d } := 0 ++
}
}, np)
}
var nums = kap.keys.map{.to_n}.sort
for n in (6 .. 14) {
var np = (10**n - 1)
printf("Kaprekar numbers <= 10^%2d: %5d\n", n, nums.count_by { .<= np })
}