Partition function P: Difference between revisions

Added 11l
m (→‎{{header|Phix}}: added syntax colouring the hard way)
(Added 11l)
Line 37:
<br><br>
 
 
=={{header|11l}}==
{{trans|Python: Alternative}}
 
<lang 11l>F partitions(n)
V p = [BigInt(1)] [+] [BigInt(0)] * n
L(i) 1 .. n
V k = 0
L
k++
V j = (k * (3 * k - 1)) I/ 2
I j > i
L.break
I k [&] 1
p[i] += p[i - j]
E
p[i] -= p[i - j]
j = (k * (3 * k + 1)) I/ 2
I j > i
L.break
I k [&] 1
p[i] += p[i - j]
E
p[i] -= p[i - j]
R p[n]
 
print(‘Partitions: ’(0.<15).map(x -> partitions(x)))
print(partitions(6666))</lang>
 
{{out}}
<pre>
Partitions: [1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 101, 135]
193655306161707661080005073394486091998480950338405932486880600467114423441282418165863
</pre>
 
=={{header|C}}==
Line 83 ⟶ 117:
Elapsed time: 0.0136 seconds
</pre>
 
 
=={{header|C++}}==
1,454

edits