3 points · by LightMachine · 8y ago · 1 comment
tot=x+x+x+x+x+x+x+x+x+x+x+x+x+x+x
x2=x+x x4=x2+x2 x8=x4+x4 tot=x+x2+x4+x8
Note that the first code is O(N=15) and the second one is O(log(N)=4).