Stirling numbers of the second kind: Difference between revisions

add FreeBASIC
m (Use aggregate_all instead of findall/max_list to find maximum value)
(add FreeBASIC)
Line 322:
7769730053598745155212806612787584787397878128370115840974992570102386086289805848025074822404843545178960761551674
</pre>
 
=={{header|FreeBASIC}}==
<lang freebasic>dim as integer S2(0 to 12, 0 to 12) 'initially set with zeroes
dim as ubyte n, k
dim as string outstr
 
function padto( i as ubyte, j as integer ) as string
return wspace(i-len(str(j)))+str(j)
end function
 
for k = 0 to 12 'calculate table
S2(k,k)=1
next k
for n = 1 to 11
for k = 1 to 12
S2(n+1,k) = k*S2(n,k) + S2(n,k-1)
next k
next n
 
print "Stirling numbers of the second kind"
print
outstr = " k"
for k=0 to 12
outstr += padto(12, k)
next k
print outstr
print " n"
for n = 0 to 12
outstr = padto(2, n)+" "
for k = 0 to 12
outstr += padto(12, S2(n, k))
next k
print outstr
next n</lang>
<pre>Stirling numbers of the second kind
 
k 0 1 2 3 4 5 6 7 8 9 10 11 12
n
0 1 0 0 0 0 0 0 0 0 0 0 0 0
1 0 1 0 0 0 0 0 0 0 0 0 0 0
2 0 1 1 0 0 0 0 0 0 0 0 0 0
3 0 1 3 1 0 0 0 0 0 0 0 0 0
4 0 1 7 6 1 0 0 0 0 0 0 0 0
5 0 1 15 25 10 1 0 0 0 0 0 0 0
6 0 1 31 90 65 15 1 0 0 0 0 0 0
7 0 1 63 301 350 140 21 1 0 0 0 0 0
8 0 1 127 966 1701 1050 266 28 1 0 0 0 0
9 0 1 255 3025 7770 6951 2646 462 36 1 0 0 0
10 0 1 511 9330 34105 42525 22827 5880 750 45 1 0 0
11 0 1 1023 28501 145750 246730 179487 63987 11880 1155 55 1 0
12 0 1 2047 86526 611501 1379400 1323652 627396 159027 22275 1705 66 1</pre>
 
=={{header|Fōrmulæ}}==
781

edits