Knuth's power tree: Difference between revisions

(Added 11l)
Line 99:
R path(:p[n]) [+] [n]
 
F tree_pow_itree_pow(x, n)
VT (r, p)Ty = ([0 = BigInt(1), 1 = BigIntT(x)], 0)
LV (ir, p) path= (n[0 = Ty(1), 1 = x], 0)
r[i] = r[i - p] * r[p]
p = i
R r[n]
 
F tree_pow_f(x, n)
V (r, p) = ([0 = 1.0, 1 = x], 0)
L(i) path(n)
r[i] = r[i - p] * r[p]
Line 114 ⟶ 108:
 
F show_pow_i(x, n)
print("#.: #.\n#.^#. = #.\n".format(n, path(n), x, n, tree_pow_itree_pow(BigInt(x), n)))
 
F show_pow_f(x, n)
print("#.: #.\n#.^#. = #.6\n".format(n, path(n), x, n, tree_pow_ftree_pow(x, n)))
 
L(x) 18
1,480

edits