Paraffins: Difference between revisions

Added 11l
(→‎{{header|Nim}}: fix compilation)
(Added 11l)
Line 95:
http://java.net/projects/projectfortress/sources/sources/content/ProjectFortress/demos/turnersParaffins0.fss?rev=3005
<br><br>
 
=={{header|11l}}==
{{trans|Nim}}
 
<lang 11l>V nMax = 250
V nBranches = 4
V rooted = [BigInt(0)] * (nMax + 1)
V unrooted = [BigInt(0)] * (nMax + 1)
rooted[0] = BigInt(1)
rooted[1] = BigInt(1)
unrooted[0] = BigInt(1)
unrooted[1] = BigInt(1)
 
F choose(m, k)
I k == 1
R m
V result = m
L(i) 1 .< k
result = result * (m + i) I/ (i + 1)
R result
 
F tree(br, n, l, sum, cnt)
V s = 0
L(b) br + 1 .. :nBranches
s = sum + (b - br) * n
I s > :nMax {R}
 
V c = choose(:rooted[n], b - br) * cnt
 
I l * 2 < s {:unrooted[s] += c}
I b == :nBranches {R}
:rooted[s] += c
L(m) (n - 1 .< 0).step(-1)
tree(b, m, l, s, c)
 
F bicenter(s)
I (s [&] 1) == 0
:unrooted[s] += :rooted[s I/ 2] * (:rooted[s I/ 2] + 1) I/ 2
 
L(n) 1 .. nMax
tree(0, n, n, 1, BigInt(1))
bicenter(n)
print(n‘: ’unrooted[n])</lang>
 
{{out}}
<pre>
1: 1
2: 1
3: 1
4: 2
5: 3
6: 5
7: 9
8: 18
9: 35
10: 75
...
244: 34576004768296889785887066794910718730985852896707505707076422305798138880427343561380451664648670542260
245: 96356944442415066997623733664230869603611716312377642117711752082444867783045964116385053282421589905891
246: 268540209617944059776303921971316267806082307732727328919911735252505071315985779867844056236080213000010
247: 748434113260252449609376828666343341456610378512725586135955779939163320693444008584504390382026391947130
248: 2086006351917005252913566124773054331962205157167696706926185063169623907656246841866717933958839366769700
249: 5814271898167303040368103945830220447130073898083466852225709084407144308593691069932064987528870826155297
250: 16206624309085062837751018464745815688226709117091506494175397665527493805947344857313038875654104100026504
</pre>
 
=={{header|C}}==
1,481

edits