Sara is trying a new type of game in which she can jump in either the left direction or in the right direction. Also after each jump the range of her jump increases by 1 unit. i.e if starts from 1 in the next jump she has to jump 2 units then 3 units and so on. Given the number of jumps as N, the range of the first jump to be 1. What will be the minimum distance Sara can be at from the starting point.write a program
Answers
Answered by
0
Answer:
n = int(input()) #number of jumps
j = 1 #innitial jump
d = 0 #distance covered
while n >= 0:
n -= j
d += j
j += 1
print(d)
Explanation:
While we are having number of jumps left, we keep covering distance.
Substracting that distance from N.
Lastly, we have our final result as d
Similar questions