Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,27 @@
import sequtils, strformat, times
import bignum
func partitions(n: int): Int =
var p = newSeqWith(n + 1, newInt())
p[0] = newInt(1)
for i in 1..n:
var k = 1
while true:
var j = k * (3 * k - 1) div 2
if j > i: break
if (k and 1) != 0:
inc p[i], p[i - j]
else:
dec p[i], p[i - j]
j = k * (3 * k + 1) div 2
if j > i: break
if (k and 1) != 0:
inc p[i], p[i - j]
else:
dec p[i], p[i - j]
inc k
result = p[n]
let t0 = cpuTime()
echo partitions(6666)
echo &"Elapsed time: {(cpuTime() - t0) * 1000:.2f} ms"