Consider the following algorithm:
i := 1
t := 0
while i ≤ n
t := t + i
i := 2i
I'm interested in finding out how many addition and multiplication operations this algorithm executes; however, I'm running into trouble. I understand that the value of i doubles after each iteration, but I don't know how to generalize the algorithm to give a correct number of operations up until the value of n. If anyone can shed some light on the issue, I'd greatly appreciate it.
Thank you!