Paraffins: Difference between revisions

Updated to work with Nim 1.4: added missing parameter types, replaced ".. <" with "..<". Also added "libheader" for "bigints" module.
m (aligned formulas, used colored window, increased whitespace.)
(Updated to work with Nim 1.4: added missing parameter types, replaced ".. <" with "..<". Also added "libheader" for "bigints" module.)
Line 1,603:
=={{header|Nim}}==
{{trans|C}}
{{libheader|bigints}}
<lang nim>import bigints
 
Line 1,616 ⟶ 1,617:
unrooted[i] = 0.initBigInt
 
proc choose(m,; BigInt; k: int32): BigInt =
result = m
if k == 1: return
for i in 1 .. < k:
result = result * (m + i) div (i + 1)
 
proc tree(br, n, l, sum: int32,; cnt: BigInt) =
var s: int32 = 0
for b in br + 1 .. nBranches:
Line 1,636 ⟶ 1,637:
tree b, m, l, s, c
 
proc bicenter(s: int32) =
if (s and 1) == 0:
unrooted[s] += rooted[s div 2] * (rooted[s div 2] + 1) div 2
Line 1,644 ⟶ 1,645:
n.bicenter
echo n, ": ", unrooted[n]</lang>
 
Output:
{{out}}
<pre>1: 1
2: 1
Anonymous user