+ 1

Whats the code for that question

program find the sum of that series 1- 1/3 + 1/5 - 1/7 + 1/9......1/n n=any number from keyboard

23rd Apr 2018, 8:19 AM
ScorpiOn AMQ
ScorpiOn AMQ - avatar
2 Answers
+ 11
Is this homework?
23rd Apr 2018, 8:24 AM
Fox
Fox - avatar
+ 4
print(sum([(-1,1)[j%2]/i for j,i in enumerate(list(range(1,int(input())+1,2)),1)]))
23rd Apr 2018, 9:12 AM
Louis
Louis - avatar