9 billion names of God the integer: Difference between revisions

Implementation for R
m (syntax highlighting fixup automation)
(Implementation for R)
 
(4 intermediate revisions by 4 users not shown)
Line 1:
{{task}}
 
{{omit from|6502 Assembly|Good luck doing this with only 64K of addressable memory}}
{{omit from|Z80 Assembly|See above}}
This task is a variation of the [[wp:The Nine Billion Names of God#Plot_summary|short story by Arthur C. Clarke]].
Line 46 ⟶ 45:
{{trans|Python}}
 
<syntaxhighlight lang="11l">V cache = [[BigInt(1)]]
F cumu(n)
L(l) :cache.len .. n
Line 124 ⟶ 123:
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
<syntaxhighlight lang=AArch64"aarch64 Assemblyassembly">
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program integerName64.s */
Line 304 ⟶ 303:
{{libheader|Ada.Numerics.Big_Numbers.Big_Integers}}
 
<syntaxhighlight lang=Ada"ada">with Ada.Text_IO;
with Ada.Numerics.Big_Numbers.Big_Integers;
 
Line 503 ⟶ 502:
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi}}
<syntaxhighlight lang=ARM"arm Assemblyassembly">
/* ARM assembly Raspberry PI */
/* program integerName.s */
Line 664 ⟶ 663:
 
=={{header|AutoHotkey}}==
<syntaxhighlight lang=AutoHotkey"autohotkey">SetBatchLines -1
 
InputBox, Enter_value, Enter the no. of lines sought
Line 756 ⟶ 755:
 
If we forgo the rows and only want to calculate <math>P(n)</math>, using the recurrence relation <math>P_n = \sum_{k=1}^n (-1)^{k+1} \Big(P_{n-k(3k-1)/2} + P_{n-k(3k+1)/2}\Big)</math> is a better way. This requires <math>O(n^2)</math> storage for caching instead the <math>O(n^3)</math>-ish for storing all the rows.
<syntaxhighlight lang="c">#include <stdio.h>
#include <gmp.h>
 
Line 810 ⟶ 809:
(this requires a System.Numerics registry reference)
 
<syntaxhighlight lang="csharp">using System;
using System.Collections.Generic;
using System.Linq;
Line 948 ⟶ 947:
===The Code===
see [[http://rosettacode.org/wiki/Talk:9_billion_names_of_God_the_integer#The_Green_Triangle The Green Triangle]].
<syntaxhighlight lang="cpp">
// Calculate hypotenuse n of OTT assuming only nothingness, unity, and hyp[n-1] if n>1
// Nigel Galloway, May 6th., 2013
Line 961 ⟶ 960:
===The Alpha and Omega, Beauty===
Before displaying the triangle the following code displays hyp as it is transformed by consequtive calls of G_hyp.
<syntaxhighlight lang="cpp">
#include <iostream>
#include <iomanip>
Line 996 ⟶ 995:
===The One True Triangle, OTT===
The following will display OTT(25).
<syntaxhighlight lang="cpp">
int main(){
N = 25;
Line 1,053 ⟶ 1,052:
===Values of Integer Partition Function===
Values of the Integer Partition function may be extracted as follows:
<syntaxhighlight lang="cpp">
#include <iostream>
int main(){
Line 1,076 ⟶ 1,075:
 
=={{header|Clojure}}==
<syntaxhighlight lang="clojure">(defn nine-billion-names [row column]
(cond (<= row 0) 0
(<= column 0) 0
Line 1,097 ⟶ 1,096:
 
=={{header|Common Lisp}}==
<syntaxhighlight lang="lisp">(defun 9-billion-names (row column)
(cond ((<= row 0) 0)
((<= column 0) 0)
Line 1,117 ⟶ 1,116:
{{trans|Ruby}}
===Naive Solution===
<syntaxhighlight lang="ruby">def g(n, g)
return 1 unless 1 < g && g < n-1
(2..g).reduce(1){ |res, q| res + (q > n-g ? 0 : g(n-g, q)) }
Line 1,155 ⟶ 1,154:
===Producing rows===
{{trans|Python}}
<syntaxhighlight lang="d">import std.stdio, std.bigint, std.algorithm, std.range;
 
auto cumu(in uint n) {
Line 1,203 ⟶ 1,202:
===Only partition functions===
{{trans|C}}
<syntaxhighlight lang="d">import std.stdio, std.bigint, std.algorithm;
 
struct Names {
Line 1,276 ⟶ 1,275:
{{trans|Python}}
 
<syntaxhighlight lang=Dart"dart">import 'dart:math';
 
List<BigInt> partitions(int n) {
Line 1,312 ⟶ 1,311:
 
In main:
<syntaxhighlight lang=Dart"dart"> import 'package:DD1_NamesOfGod/DD1_NamesOfGod.dart' as names_of_god;
 
main(List<String> arguments) {
Line 1,340 ⟶ 1,339:
=={{header|Dyalect}}==
 
<syntaxhighlight lang=Dyalect"dyalect">var cache = [[1]]
func namesOfGod(n) {
Line 1,401 ⟶ 1,400:
{{trans|Ruby}}
Naive Solution
<syntaxhighlight lang="elixir">defmodule God do
def g(n,g) when g == 1 or n < g, do: 1
def g(n,g) do
Line 1,446 ⟶ 1,445:
 
Step 1: Print the pyramid for a smallish number of names. The P function is implement as described on [http://mathworld.wolfram.com/PartitionFunctionP.html partition function], (see 59 on that page). This is slow for N > 100, but works fine for the example: 10.
<syntaxhighlight lang=Erlang"erlang">
-module(triangle).
-export([start/1]).
Line 1,502 ⟶ 1,501:
=={{header|Factor}}==
{{works with|Factor|0.99 2020-01-23}}
<syntaxhighlight lang="factor">USING: combinators io kernel math math.ranges memoize prettyprint
sequences ;
 
Line 1,603 ⟶ 1,602:
=={{header|FreeBASIC}}==
{{libheader|GMP}}
<syntaxhighlight lang="freebasic">' version 03-11-2016
' compile with: fbc -s console
 
Line 1,730 ⟶ 1,729:
This demonstrates using a class that memoizes results to improve efficiency and reduce later calculation. It verifies its results against Frink's built-in and much more memory-and-space-efficient partitionCount function which uses Euler's pentagonal method for counting partitions.
 
<syntaxhighlight lang="frink">
class PartitionCount
{
Line 1,822 ⟶ 1,821:
=={{header|GAP}}==
The partition function is built-in.
<syntaxhighlight lang="gap">PrintArray(List([1 .. 25], n -> List([1 .. n], k -> NrPartitions(n, k))));
 
[ [ 1 ],
Line 1,857 ⟶ 1,856:
 
=={{header|Go}}==
<syntaxhighlight lang="go">package main
 
import (
Line 1,930 ⟶ 1,929:
 
=={{header|Groovy}}==
<syntaxhighlight lang="groovy">
def partitions(c)
{
Line 2,005 ⟶ 2,004:
 
=={{header|Haskell}}==
<syntaxhighlight lang="haskell">import Data.List (mapAccumL)
 
cumu :: [[Integer]]
Line 2,049 ⟶ 2,048:
{{trans|Python}}
 
<syntaxhighlight lang="unicon">procedure main(A)
n := integer(!A) | 10
every r := 2 to (n+1) do write(right(r-1,2),": ",showList(row(r)))
Line 2,098 ⟶ 2,097:
=={{header|J}}==
Recursive calculation of a row element:
<syntaxhighlight lang="j">T=: 0:`1:`(($:&<:+ - $: ])`0:@.(0=]))@.(1+*@-) M. "0</syntaxhighlight>
Calculation of the triangle:
<syntaxhighlight lang="j">rows=: <@(#~0<])@({: T ])\@i.</syntaxhighlight>
'''Show triangle''':
<syntaxhighlight lang="j"> ({.~1+1 i:~ '1'=])"1 ":> }.rows 1+10
1
1 1
Line 2,117 ⟶ 2,116:
 
Calculate row sums:
<syntaxhighlight lang="j">rowSums=: 3 :0"0
z=. (y+1){. 1x
for_ks. <\1+i.y do.
Line 2,135 ⟶ 2,134:
Translation of [[9_billion_names_of_God_the_integer#Python|Python]] via [[9_billion_names_of_God_the_integer#D|D]]
{{works with|Java|8}}
<syntaxhighlight lang="java">import java.math.BigInteger;
import java.util.*;
import static java.util.Arrays.asList;
Line 2,197 ⟶ 2,196:
===Solution 1===
{{trans|Python}}
<syntaxhighlight lang=JavaScript"javascript">
(function () {
var cache = [
Line 2,262 ⟶ 2,261:
===Solution 2===
Clean and straightforward solution
<syntaxhighlight lang="javascript">
function genTriangle(n){ // O(n^3) time and O(n^2) space
var a = new Array(n)
Line 2,334 ⟶ 2,333:
G(12345) = 69420357953926116819562977205209384460667673094671463620270321700806074195845953959951425306140971942519870679768681736
</pre>
 
=={{header|jq}}==
''Adapted from [[#Wren|Wren]]''
 
'''Works with gojq, the Go implementation of jq, and with fq.'''
 
This entry uses the same algorithm as [[#Wren|Wren]], but on my 16GM
RAM machine, wren version 0.4.0 runs out of memory computing P(12345),
so that goal has been excluded here.
 
The integer arithmetic supported by the C implementation of jq lacks the precision
required for computing P(1234) accurately, so the output shown below is based on
a run of gojq.
 
The values shown in the output agree with those obtained using the programs
at [[Partition_function_P#jq]].
<syntaxhighlight lang=jq>
def cumu:
. as $n
| reduce range(1; $n+1) as $l ( {cache: [[1]]};
.r = [0]
| reduce range(1; $l+1) as $x (.;
.min = $l - $x
| if ($x < .min) then .min = $x else . end
| .r = .r + [.r[-1] + .cache[$l - $x][.min] ] )
| .cache = .cache + [.r] )
| .cache[$n] ;
 
def row:
cumu as $r
| reduce range(0; .) as $i ([]; . + [$r[$i+1] - $r[$i]] );
 
def task:
"Rows:",
(range(1; 26) | [ ., row]),
"\nSums:",
( (23, 123, 1234) # 12345 is a stretch for memory even using wren
| [., cumu[-1]] ) ;
</syntaxhighlight>
 
'''Invocation''': gojq -n -rcf 9-billion.jq
{{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]]
[11,[1,5,10,11,10,7,5,3,2,1,1]]
[12,[1,6,12,15,13,11,7,5,3,2,1,1]]
[13,[1,6,14,18,18,14,11,7,5,3,2,1,1]]
[14,[1,7,16,23,23,20,15,11,7,5,3,2,1,1]]
[15,[1,7,19,27,30,26,21,15,11,7,5,3,2,1,1]]
[16,[1,8,21,34,37,35,28,22,15,11,7,5,3,2,1,1]]
[17,[1,8,24,39,47,44,38,29,22,15,11,7,5,3,2,1,1]]
[18,[1,9,27,47,57,58,49,40,30,22,15,11,7,5,3,2,1,1]]
[19,[1,9,30,54,70,71,65,52,41,30,22,15,11,7,5,3,2,1,1]]
[20,[1,10,33,64,84,90,82,70,54,42,30,22,15,11,7,5,3,2,1,1]]
[21,[1,10,37,72,101,110,105,89,73,55,42,30,22,15,11,7,5,3,2,1,1]]
[22,[1,11,40,84,119,136,131,116,94,75,56,42,30,22,15,11,7,5,3,2,1,1]]
[23,[1,11,44,94,141,163,164,146,123,97,76,56,42,30,22,15,11,7,5,3,2,1,1]]
[24,[1,12,48,108,164,199,201,186,157,128,99,77,56,42,30,22,15,11,7,5,3,2,1,1]]
[25,[1,12,52,120,192,235,248,230,201,164,131,100,77,56,42,30,22,15,11,7,5,3,2,1,1]]
 
Sums:
[23,1255]
[123,2552338241]
[1234,156978797223733228787865722354959930]
</pre>
 
 
=={{header|Julia}}==
<syntaxhighlight lang="julia">
using Combinatorics, StatsBase
 
Line 2,418 ⟶ 2,493:
=={{header|Kotlin}}==
{{trans|Swift}}
<syntaxhighlight lang="scala">import java.lang.Math.min
import java.math.BigInteger
import java.util.ArrayList
Line 2,490 ⟶ 2,565:
=={{header|Lasso}}==
This code is derived from the Python solution, as an illustration of the difference in array behaviour (indexes, syntax), and loop and query expression as alternative syntax to "for".
<syntaxhighlight lang=Lasso"lasso">define cumu(n::integer) => {
loop(-from=$cache->size,-to=#n+1) => {
local(r = array(0), l = loop_count)
Line 2,557 ⟶ 2,632:
 
=={{header|Lua}}==
<syntaxhighlight lang="lua">function nog(n)
local tri = {{1}}
for r = 2, n do
Line 2,610 ⟶ 2,685:
 
=={{header|Maple}}==
<syntaxhighlight lang="maple">TriangleLine(n) := map(rhs, Statistics :- Tally(map(x -> x[-1], combinat:-partition(n)))):
Triangle := proc(m)
local i;
Line 2,631 ⟶ 2,706:
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<syntaxhighlight lang="mathematica">Table[Last /@ Reverse@Tally[First /@ IntegerPartitions[n]], {n, 10}] // Grid</syntaxhighlight>
{{out}}
<pre>1
Line 2,645 ⟶ 2,720:
 
Here I use the bulit-in function PartitionsP to calculate <math>P(n)</math>.
<syntaxhighlight lang="mathematica">PartitionsP /@ {23, 123, 1234, 12345}</syntaxhighlight>
{{out}}
<pre>{1255, 2552338241, 156978797223733228787865722354959930, 69420357953926116819562977205209384460667673094671463620270321700806074195845953959951425306140971942519870679768681736}</pre>
 
<syntaxhighlight lang="mathematica">DiscretePlot[PartitionsP[n], {n, 1, 999}, PlotRange -> All]</syntaxhighlight>
[[File:9 billion names of God the integer Mathematica.png]]
 
=={{header|Maxima}}==
<syntaxhighlight lang="maxima">for n thru 25 do print(makelist(length(integer_partitions(n-k,k)),k,1,n))$</syntaxhighlight>
{{out}}
<pre>[1]
Line 2,682 ⟶ 2,757:
 
Using the built-in function to calculate <math>P(n)</math>:
<syntaxhighlight lang="maxima">makelist(num_partitions(n),n,[23,123,1234,12345]);</syntaxhighlight>
{{out}}
<pre>(%o1) [1255, 2552338241, 156978797223733228787865722354959930, 69420357953926116819562977205209384460667673094671463620270321700806074195845953959951425306140971942519870679768681736]</pre>
Line 2,688 ⟶ 2,763:
=={{header|Nim}}==
{{trans|Python}}
<syntaxhighlight lang="nim">import bigints
 
var cache = @[@[1.initBigInt]]
Line 2,733 ⟶ 2,808:
Faster version:
{{trans|C}}
<syntaxhighlight lang="nim">import bigints
 
var p = @[1.initBigInt]
Line 2,773 ⟶ 2,848:
 
=={{header|OCaml}}==
<syntaxhighlight lang="ocaml">
let get, sum_unto =
let cache = ref [||]
Line 2,898 ⟶ 2,973:
 
=={{header|Ol}}==
<syntaxhighlight lang="scheme">
(define (nine-billion-names row column)
(cond
Line 2,955 ⟶ 3,030:
=={{header|PARI/GP}}==
 
<syntaxhighlight lang="parigp">row(n)=my(v=vector(n)); forpart(i=n,v[i[#i]]++); v;
show(n)=for(k=1,n,print(row(k)));
show(25)
Line 3,017 ⟶ 3,092:
=={{header|Perl}}==
{{libheader|ntheory}}
<syntaxhighlight lang="perl">use ntheory qw/:all/;
 
sub triangle_row {
Line 3,037 ⟶ 3,112:
 
{{trans|Raku}}
<syntaxhighlight lang="perl">
use strict;
use warnings;
Line 3,117 ⟶ 3,192:
 
=={{header|Phix}}==
<!--<syntaxhighlight lang=Phix"phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">-- demo\rosetta\9billionnames.exw</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
Line 3,182 ⟶ 3,257:
{{trans|C}}
{{libheader|Phix/mpfr}}
<!--<syntaxhighlight lang=Phix"phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">include</span> <span style="color: #004080;">mpfr</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
Line 3,226 ⟶ 3,301:
=== Third and last, a simple plot ===
{{libheader|Phix/pGUI}}
<!--<syntaxhighlight lang=Phix"phix">-->
<span style="color: #008080;">include</span> <span style="color: #000000;">pGUI</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
<span style="color: #7060A8;">IupOpen</span><span style="color: #0000FF;">()</span>
Line 3,262 ⟶ 3,337:
=={{header|Phixmonti}}==
{{trans|Yabasic}}
<syntaxhighlight lang=Phixmonti"phixmonti">/# Rosetta Code problem: http://rosettacode.org/wiki/9_billion_names_of_God_the_integer
by Galileo, 05/2022 #/
 
Line 3,319 ⟶ 3,394:
===The triangle, using constraint modelling===
Using constraint modeling to generate all the partitions 1..25.
<syntaxhighlight lang=Picat"picat">import cp.
 
main =>
Line 3,378 ⟶ 3,453:
===Number of partitions===
This is the Picat solution of [http://rosettacode.org/wiki/Partition_function_P Partition_function_P].
<syntaxhighlight lang=Picat"picat">% Number of partitions
go2 =>
foreach(N in [23,123,1234,12345,123456])
Line 3,414 ⟶ 3,489:
===Recursion===
Here is a port of the Haskell code from [http://oeis.org/A000041 oeis.org/A000041]. Though for 12345 it's too slow (and eats much RAM).
<syntaxhighlight lang=Picat"picat">pc(N) = pc(1,N).
table
pc(_,0) = 1.
Line 3,422 ⟶ 3,497:
=={{header|PicoLisp}}==
{{trans|Python}}
<syntaxhighlight lang=PicoLisp"picolisp">(de row (N)
(let C '((1))
(do N
Line 3,510 ⟶ 3,585:
{{trans|Python}}
 
<syntaxhighlight lang=Pike"pike">array cumu(int n) {
array(array(int)) cache = ({({1})});
 
Line 3,569 ⟶ 3,644:
 
=={{header|PureBasic}}==
<syntaxhighlight lang="purebasic">
Define nMax.i=25, n.i, k.i
Dim pfx.s(1)
Line 3,674 ⟶ 3,749:
 
=={{header|Python}}==
<syntaxhighlight lang="python">cache = [[1]]
def cumu(n):
for l in range(len(cache), n+1):
Line 3,714 ⟶ 3,789:
</pre>
To calculate partition functions only:
<syntaxhighlight lang="python">def partitions(N):
diffs,k,s = [],1,1
while k * (3*k-1) < 2*N:
Line 3,735 ⟶ 3,810:
This version uses only a fraction of the memory and of the running time, compared to the first one that has to generate all the rows:
{{trans|C}}
<syntaxhighlight lang="python">def partitions(n):
partitions.p.append(0)
 
Line 3,778 ⟶ 3,853:
1234: 156978797223733228787865722354959930
12345: 69420357953926116819562977205209384460667673094671463620270321700806074195845953959951425306140971942519870679768681736</pre>
 
=={{header|R}}==
<syntaxhighlight lang="racket">
library(partitions)
library(stringi)
 
get_row <- function(x) unname(table(parts(x)[1,]))
 
center_string <- function(s,pad_len=80) stri_pad_both(s,(pad_len - length(s))," ")
for (i in 1:25) cat(center_string(stri_c(get_row(i),collapse = " "),80),"\n")
 
cat("The sum of G(25) is:", sum(get_row(25)),"\n")
 
</syntaxhighlight>
{{out}}
<pre>
1
1 1
1 1 1
1 2 1 1
1 2 2 1 1
1 3 3 2 1 1
1 3 4 3 2 1 1
1 4 5 5 3 2 1 1
1 4 7 6 5 3 2 1 1
1 5 8 9 7 5 3 2 1 1
1 5 10 11 10 7 5 3 2 1 1
1 6 12 15 13 11 7 5 3 2 1 1
1 6 14 18 18 14 11 7 5 3 2 1 1
1 7 16 23 23 20 15 11 7 5 3 2 1 1
1 7 19 27 30 26 21 15 11 7 5 3 2 1 1
1 8 21 34 37 35 28 22 15 11 7 5 3 2 1 1
1 8 24 39 47 44 38 29 22 15 11 7 5 3 2 1 1
1 9 27 47 57 58 49 40 30 22 15 11 7 5 3 2 1 1
1 9 30 54 70 71 65 52 41 30 22 15 11 7 5 3 2 1 1
1 10 33 64 84 90 82 70 54 42 30 22 15 11 7 5 3 2 1 1
1 10 37 72 101 110 105 89 73 55 42 30 22 15 11 7 5 3 2 1 1
1 11 40 84 119 136 131 116 94 75 56 42 30 22 15 11 7 5 3 2 1 1
1 11 44 94 141 163 164 146 123 97 76 56 42 30 22 15 11 7 5 3 2 1 1
1 12 48 108 164 199 201 186 157 128 99 77 56 42 30 22 15 11 7 5 3 2 1 1
1 12 52 120 192 235 248 230 201 164 131 100 77 56 42 30 22 15 11 7 5 3 2 1 1
 
The sum of G(25) is: 1958
 
</pre>
 
=={{header|Racket}}==
<syntaxhighlight lang="racket">#lang racket
 
(define (cdr-empty ls) (if (empty? ls) empty (cdr ls)))
Line 3,840 ⟶ 3,961:
To save a bunch of memory, this algorithm throws away all the numbers that it knows it's not going to use again, on the assumption that the function will only be called with increasing values of $n. (It could easily be made to recalculate if it notices a regression.)
 
<syntaxhighlight lang=perl6"raku" line>my @todo = $[1];
my @sums = 0;
sub nextrow($n) {
Line 3,909 ⟶ 4,030:
 
=={{header|Red}}==
<syntaxhighlight lang=Rebol"rebol">
Red []
 
Line 4,024 ⟶ 4,145:
</big>
which is derived from Euler's generating function.
<syntaxhighlight lang="rexx">/*REXX program generates and displays a number triangle for partitions of a number. */
numeric digits 400 /*be able to handle larger numbers. */
parse arg N . /*obtain optional argument from the CL.*/
Line 4,141 ⟶ 4,262:
=={{header|Ruby}}==
===Naive Solution===
<syntaxhighlight lang="ruby">
# Generate IPF triangle
# Nigel_Galloway: May 1st., 2013.
Line 4,183 ⟶ 4,304:
 
===Full Solution===
<syntaxhighlight lang="ruby">
# Find large values of IPF
# Nigel_Galloway: May 1st., 2013.
Line 4,225 ⟶ 4,346:
=={{header|Rust}}==
{{trans|Python}}
<syntaxhighlight lang="rust">extern crate num;
 
use std::cmp;
Line 4,306 ⟶ 4,427:
=={{header|Scala}}==
===Naive Solution===
<syntaxhighlight lang="scala">
object Main {
 
Line 4,386 ⟶ 4,507:
 
===Full Solution===
<syntaxhighlight lang=Scala"scala">val cache = new Array[BigInt](15000)
cache(0) = 1
val cacheNaive = scala.collection.mutable.Map[Tuple2[Int, Int], BigInt]()
Line 4,465 ⟶ 4,586:
 
=={{header|scheme}}==
<syntaxhighlight lang="scheme">(define (f m n)
(define (sigma g x y)
(define (sum i)
Line 4,515 ⟶ 4,636:
 
=={{header|Sidef}}==
<syntaxhighlight lang="ruby">var cache = [[1]]
 
func cumu (n) {
Line 4,571 ⟶ 4,692:
 
=={{header|SPL}}==
<syntaxhighlight lang="spl">'print triangle
> n, 1..25
k = 50-n*2
Line 4,644 ⟶ 4,765:
 
=={{header|Stata}}==
<syntaxhighlight lang="stata">mata
function part(n) {
a = J(n,n,.)
Line 4,683 ⟶ 4,804:
=={{header|Swift}}==
{{trans|Python}}
<syntaxhighlight lang=Swift"swift">var cache = [[1]]
func namesOfGod(n:Int) -> [Int] {
for l in cache.count...n {
Line 4,755 ⟶ 4,876:
=={{header|Tcl}}==
{{trans|Python}}
<syntaxhighlight lang="tcl">set cache 1
proc cumu {n} {
global cache
Line 4,810 ⟶ 4,931:
{{trans|VBA}}
Since uBasic/4tH features a single array of 256 elements, level "15" is the best that can be achieved.
<syntaxhighlight lang="text">Proc _NineBillionNames(15)
End
 
Line 4,853 ⟶ 4,974:
0 OK, 0:30 </pre>
=={{header|VBA}}==
<syntaxhighlight lang="vb">Public Sub nine_billion_names()
Dim p(25, 25) As Long
p(1, 1) = 1
Line 4,889 ⟶ 5,010:
1 9 30 54 70 71 65 52 41 30 22 15 11 7 5 3 2 1 1</pre>
 
=={{header|V (Vlang)}}==
{{trans|Go}}
<syntaxhighlight lang="v (vlang)">import math.big
 
fn int_min(a int, b int) int {
Line 4,962 ⟶ 5,083:
{{libheader|Wren-big}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang=ecmascript"wren">import "./big" for BigInt
import "./fmt" for Fmt
 
var cache = [[BigInt.one]]
Line 5,034 ⟶ 5,155:
=={{header|Yabasic}}==
{{trans|VBA}}
<syntaxhighlight lang=Yabasic"yabasic">clear screen
 
Sub nine_billion_names(rows)
Line 5,059 ⟶ 5,180:
{{trans|C}}
Takes its time getting to 100,000 but it does. Uses the GMP big int library. Does the big int math in place to avoid garbage creation.
<syntaxhighlight lang="zkl">var [const] BN=Import.lib("zklBigNum");
const N=0d100_000;
Line 5,076 ⟶ 5,197:
}
}</syntaxhighlight>
<syntaxhighlight lang="zkl">idx:=T(23, 123, 1234, 12345, 20000, 30000, 40000, 50000, N);
p[0].set(1);
 
Line 5,093 ⟶ 5,214:
100000: 27493510569775696512677516320986352688173429315980054758203125984302147328114964173055050741660736621590157844774296248940493063070200461792764493033510116079342457190155718943509725312466108452006369558934464248716828789832182345009262853831404597021307130674510624419227311238999702284408609370935531629697851569569892196108480158600569421098519
</pre>
{{omit from|6502 Assembly|Good luck doing this with only 64K of addressable memory}}
{{omit from|Z80 Assembly|See above}}
3

edits