9 billion names of God the integer: Difference between revisions
Content added Content deleted
m (→{{header|FreeBASIC}}: the limit for the ulongint function is 415) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 41: | Line 41: | ||
* [[Partition function P]] |
* [[Partition function P]] |
||
<br><br> |
<br><br> |
||
=={{header|11l}}== |
|||
{{trans|Python}} |
|||
<lang 11l>V cache = [[BigInt(1)]] |
|||
F cumu(n) |
|||
L(l) :cache.len .. n |
|||
V r = [BigInt(0)] |
|||
L(x) 1 .. l |
|||
r.append(r.last + :cache[l - x][min(x, l - x)]) |
|||
:cache.append(r) |
|||
R :cache[n] |
|||
F row(n) |
|||
V r = cumu(n) |
|||
R (0 .< n).map(i -> @r[i + 1] - @r[i]) |
|||
print(‘rows:’) |
|||
L(x) 1..10 |
|||
print(‘#2:’.format(x)‘ ’row(x)) |
|||
print("\nsums:") |
|||
V pp = [BigInt(1)] |
|||
F partitions(n) |
|||
:pp.append(BigInt(0)) |
|||
L(k) 1 .. n |
|||
V d = n - k * (3 * k - 1) I/ 2 |
|||
I d < 0 |
|||
L.break |
|||
I k [&] 1 |
|||
:pp[n] += :pp[d] |
|||
E |
|||
:pp[n] -= :pp[d] |
|||
d -= k |
|||
I d < 0 |
|||
L.break |
|||
I k [&] 1 |
|||
:pp[n] += :pp[d] |
|||
E |
|||
:pp[n] -= :pp[d] |
|||
R :pp.last |
|||
V ns = Set([23, 123, 1234, 12345]) |
|||
V max_ns = max(ns) |
|||
L(i) 1 .. max_ns |
|||
I i > max_ns |
|||
L.break |
|||
V p = partitions(i) |
|||
I i C ns |
|||
print(‘#6: #.’.format(i, p))</lang> |
|||
{{out}} |
|||
<pre> |
|||
rows: |
|||
1: [1] |
|||
2: [1, 1] |
|||
3: [1, 1, 1] |
|||
4: [1, 2, 1, 1] |
|||
5: [1, 2, 2, 1, 1] |
|||
6: [1, 3, 3, 2, 1, 1] |
|||
7: [1, 3, 4, 3, 2, 1, 1] |
|||
8: [1, 4, 5, 5, 3, 2, 1, 1] |
|||
9: [1, 4, 7, 6, 5, 3, 2, 1, 1] |
|||
10: [1, 5, 8, 9, 7, 5, 3, 2, 1, 1] |
|||
sums: |
|||
23: 1255 |
|||
123: 2552338241 |
|||
1234: 156978797223733228787865722354959930 |
|||
12345: 69420357953926116819562977205209384460667673094671463620270321700806074195845953959951425306140971942519870679768681736 |
|||
</pre> |
|||
=={{header|AArch64 Assembly}}== |
=={{header|AArch64 Assembly}}== |
||
{{works with|as|Raspberry Pi 3B version Buster 64 bits}} |
{{works with|as|Raspberry Pi 3B version Buster 64 bits}} |
||
Line 218: | Line 297: | ||
Number too large !!. |
Number too large !!. |
||
</pre> |
</pre> |
||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
{{trans|C#}} {{trans|VBA}} |
{{trans|C#}} {{trans|VBA}} |