Knuth's power tree: Difference between revisions
Content added Content deleted
Alextretyak (talk | contribs) (Added 11l) |
Alextretyak (talk | contribs) |
||
Line 99: | Line 99: | ||
R path(:p[n]) [+] [n] |
R path(:p[n]) [+] [n] |
||
F |
F tree_pow(x, n) |
||
T Ty = T(x) |
|||
V (r, p) = ([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) |
L(i) path(n) |
||
r[i] = r[i - p] * r[p] |
r[i] = r[i - p] * r[p] |
||
Line 114: | Line 108: | ||
F show_pow_i(x, n) |
F show_pow_i(x, n) |
||
print("#.: #.\n#.^#. = #.\n".format(n, path(n), x, n, |
print("#.: #.\n#.^#. = #.\n".format(n, path(n), x, n, tree_pow(BigInt(x), n))) |
||
F show_pow_f(x, n) |
F show_pow_f(x, n) |
||
print("#.: #.\n#.^#. = #.6\n".format(n, path(n), x, n, |
print("#.: #.\n#.^#. = #.6\n".format(n, path(n), x, n, tree_pow(x, n))) |
||
L(x) 18 |
L(x) 18 |