I need to print the result for this series: 2, 4, 7, 28, 33, 198...
When x is 1 result should be 2
When x is 2 result should be 4
When x is 3 result should be 7
And so on
I have this but it's not working:
n = int(input( "Enter value N: "))
r = 0
for i in range(1,n+1):
if(n%2==0):
r=r*i
else:
r=r+i
print(r)
With n=6 the following code print: 2, 4, 7, 28, 33 and 198.
n = int(input("Enter value N: "))
r = 1
for i in range(1, n+1):
if i%2==0:
r*=i
else:
r+=i
print(r)