9 billion names of God the integer: Difference between revisions
Content deleted Content added
+add Pike |
|||
Line 3,346:
69420357953926116819562977205209384460667673094671463620270321700806074195845953959951425306140971942519870679768681736
0.626 sec</pre>
=={{header|Pike}}==
{{trans|Python}}
<lang Pike>array cumu(int n) {
array(array(int)) cache = ({({1})});
for(int l = sizeof(cache); l < n + 1; l++) {
array(int) r = ({0});
for(int x = 1; x < l + 1; x++) {
r = Array.push(r, r[-1] + cache[l - x][min(x, l-x)]);
}
cache = Array.push(cache, r);
}
return cache[n];
}
array row(int n) {
array r = cumu(n);
array res = ({});
for (int i = 0; i < n; i++) {
res = Array.push(res, r[i+1] - r[i]);
}
return res;
}
int main() {
write("rows:\n");
for(int x = 1; x < 11; x++) {
write("%2d: ", x);
for(int i = 0; i < sizeof(row(x)); i++) {
write((string)row(x)[i] + " ");
}
write("\n");
}
array(int) sum_n = ({23, 123, 1234, 12345});
write("\nsums:\n");
for (int x = 0; x < sizeof(sum_n); x++) {
write((string)sum_n[x] + " " + (string)cumu(sum_n[x])[-1] + "\n");
}
return 0;
}</lang>
{{out}} Not wait for "12345" output.
<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
^C</pre>
=={{header|PureBasic}}==
|