mx @kitten, true! we can prove this by induction on the depth.
for depth = 0, there is exactly one node, and 2^(0+1)-1 = 1. so the formula works in the base case.
now suppose we know it is true for all trees up to a given depth d. a tree with depth d+1 looks lik two trees of depth d connected by an additional node. so the number of nodes is two times the number of nodes in a tree of depth d, plus one. 2*(2^(d+1)-1) + 1 = 2*(2^(d+1)) - 2 - 1 = 2^((d+1)+1) - 1, showing that the formula holds for depth d+1 if it holds for depth d.
by induction, we conclude the formula is true for all depths ≥ 0.
mx @kitten, why not? the sum of a geometric sequence in base n is, up to accounting for starting and ending points, n to the power something.
another proof: let the sum S be equal to 1 + n + n^2 + ... + n^d. then nS = n + n^2 + ... + n^(d+1). so nS - S = n^(d+1) - 1. divide by n - 1 on both sides to get S = (n^(d+1) - 1) / (n - 1).
for n = 2, n - 1 = 2 - 1 = 1, so the sum is 2^(d+1) - 1, as we expected.