Reputation: 23
I have a math expression in my head which I want to write down on paper but I'm not sure exactly how to. I know I need to use sigma but I'm not sure what the function should be. I know how to write a python code for it so I wrote that out, but I'm still not sure how to write it out as a math function. This is the code:
def multiply_sum(integer):
whatever = 1
final = 0
for i in range(1, integer + 1):
whatever = whatever * 2
final += whatever
return final
Upvotes: 0
Views: 106
Reputation: 7000
You could indeed compute the sum, but if you just want the notation, it is:
Upvotes: 0
Reputation: 1238
You're just summing 2, 4, 8, ..., 2^integer - a geometric sequence 2 * 2^i, i = 0, 1, 2... It sums up to 2^(integer+1) - 2.
You can read more about geometric series, generic formulas for the sum here and some properties here: https://en.wikipedia.org/wiki/Geometric_series.
Upvotes: 2