• VintageGenious@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    0
    ·
    3 months ago

    The use of for makes sense.

    k=0; for (i=0; i<n; i++) k=k+f(i); is the same as k=\sum_{i=0}^{n-1} f(i)

    and

    k=1; for (i=0; i<n; i++) k=k*f(i); is the same as k=\prod_{i=0}^{n-1} f(i)

    In our case, f(i)=1+r and k=1; for (i=0; i<n; i++) k*(1+r); is the same as k=\prod_{i=0}^{n-1} (1+r) = (1+r)^n

    All of that just to say that exponentiation is an iteration of multiplication, the same way that multiplication is an iteration of addition