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,18 @@
from math import sqrt
const N = 524_000_000.int32
proc sumProperDivisors(someNum: int32, chk4less: bool): int32 =
result = 1
let maxPD = sqrt(someNum.float).int32
let offset = someNum mod 2
for divNum in countup(2 + offset, maxPD, 1 + offset):
if someNum mod divNum == 0:
result += divNum + someNum div divNum
if chk4less and result >= someNum:
return 0
for n in countdown(N, 2):
let m = sumProperDivisors(n, true)
if m != 0 and n == sumProperDivisors(m, false):
echo $n, " ", $m

View file

@ -0,0 +1,17 @@
from math import sqrt
const N = 524_000_000.int32
var x = newSeq[int32](N+1)
for i in 2..sqrt(N.float).int32:
var p = i*i
x[p] += i
var j = i + i
while (p += i; p <= N):
j.inc
x[p] += j
for m in 4..N:
let n = x[m] + 1
if n < m and n != 0 and m == x[n] + 1:
echo n, " ", m