human
Find the number of jumps to reach X in the number line from zero | Utility function to calculate sum of numbers from 1 to x.
Function to find the number of jumps to reach X in the number line from zero.
First make number positive Answer will be same either it is Positive or negative.
To store the required answer.
Continue till number is lesser or not in same parity.
Return the required answer.
Driver code"
Solution in Python:
assistant
#Here is code to find the number of jumps to reach X in the number line from zero and the other steps required.
 def getsum ( x ) :
	return int ( ( x * ( x + 1 ) ) / 2 )
def countJumps ( n ) :
	n = abs ( n )
	ans = 0
	while ( getsum ( ans ) < n or ( getsum ( ans ) - n ) & 1 ) :
		ans += 1
	return ans
if __name__ == ' _ _ main _ _ ' :
	n = 9
	print ( countJumps ( n ) )