You have a jumpy ball. You throw it up from the ground up to a height of H. The ball is jumpy, so when it comes back to the ground, it rebounds and goes up again to a distance of floor(H/2). This keeps on repeating until it can't rebound anymore. You need to find the total distance traveled by the ball.
Example 1:
Input:
H = 10
Output:
36
Explanation:
H is 10. From ground to H it travels d=10.
From H to ground it travels d=10+10. Now H
becomes floor(10/2). So ball rebounds to d=10+10+5.
It goes down to the ground. d=10+10+5+5. Now H
becomes floor(5/2). So ball rebounds to d=10+10+5+5+2.
The ball goes down. d=10+10+5+5+2+2. H becomes
floor(2/2). So ball rebounds to d=10+10+5+5+2+2+1.
It goes down to the ground. d=10+10+5+5+2+2+1+1.
H becomes floor(1/2). H is zero so no rebound.
Total d=36.
Example 2:
Input:
H = 20
Output:
76
Your Task:  
You don't need to read input or print anything. Your task is to complete the function jumpyBall() which takes an integer H as an input parameter and returns the total distance traveled by the ball.
Expected Time Complexity: O(log H)
Expected Auxiliary Space: O(1)
Constraints:
0 <= H <= 10^{15}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3

class Solution:
    def jumpyBall(self, N):
    	#code here 

Solutions:
class Solution:

	def jumpyBall(self, N):
		d = 0
		while N != 0:
			d = d + N + N
			N = N // 2
		return d


class Solution:

	def jumpyBall(self, N):
		if N == 0:
			return 0
		return N * 2 + self.jumpyBall(int(N / 2))


class Solution:

	def jumpyBall(self, N):
		ans = 0
		while N:
			ans += 2 * N
			N //= 2
		return int(ans)


class Solution:

	def jumpyBall(self, N):
		sum = 0
		while N > 0:
			sum += N * 2
			N = int(N / 2)
		return sum


class Solution:

	def jumpyBall(self, N):
		l = []
		while N > 0:
			l.append(N)
			N = N // 2
		return sum(l) * 2


class Solution:

	def jumpyBall(self, N):
		i = 0
		while N >= 1:
			i += N
			N //= 2
		return i * 2


class Solution:

	def jumpyBall(self, N):
		r = [N]
		while N != 0:
			N = N // 2
			r.append(N)
		return 2 * sum(r)
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		ans = ob.jumpyBall(N)
		print(ans)


class Solution:

	def jumpyBall(self, n):
		c = 0
		while n > 0:
			c += 2 * n
			n = n // 2
		return c
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		ans = ob.jumpyBall(N)
		print(ans)


import math

class Solution:

	def jumpyBall(self, N):
		d = 0
		while N != 0:
			d = d + 2 * N
			N = math.floor(N / 2)
		return d
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		ans = ob.jumpyBall(N)
		print(ans)


class Solution:

	def jumpyBall(self, N):
		dist = 0
		while N > 0:
			dist += N * 2
			N //= 2
		return dist


class Solution:

	def jumpyBall(self, N):
		d = 0
		while N >= 1:
			d = d + 2 * N
			N = int(N / 2)
		return d


class Solution:

	def jumpyBall(self, N):
		s = 0
		while N > 0:
			s += 2 * N
			N = N // 2
		return s


class Solution:

	def jumpyBall(self, N):
		res = 0
		while N > 0:
			res += N * 2
			N //= 2
		return res


class Solution:

	def jumpyBall(self, N):
		tot_distance = 0
		while N:
			tot_distance += 2 * N
			N = N // 2
		return tot_distance


class Solution:

	def jumpyBall(self, N):
		d = 2 * N
		N = N >> 1
		while N:
			d += 2 * N
			N = N >> 1
		return d


class Solution:

	def jumpyBall(self, N):
		l = list()
		l.append(N)
		temp = N
		while temp != 0:
			t = temp // 2
			l.append(t)
			temp = t
		return sum([i * 2 for i in l])


class Solution:

	def jumpyBall(self, N):
		result = 0
		while N > 0:
			result += 2 * N
			N = N // 2
		return result


import math

class Solution:

	def jumpyBall(self, N):
		s = 0
		while N != 0:
			s = s + N + N
			N = math.floor(N / 2)
		return s


class Solution:

	def jumpyBall(self, N):
		p = 0
		while N != 0:
			p = p + 2 * N
			N = N // 2
		return p


class Solution:

	def jumpyBall(self, N):
		dis = 0
		while N > 0:
			dis += 2 * N
			N = N // 2
		return dis


class Solution:

	def jumpyBall(self, N):
		if N == 0:
			return N
		ans = 1
		while N > 1:
			ans += N
			N = N // 2
		return ans * 2


class Solution:

	def jumpyBall(self, N):
		distance = N + N
		while N > 0:
			distance += N // 2 + N // 2
			N //= 2
		return distance


import math

class Solution:

	def jumpyBall(self, N):
		temp = 0
		sum = 2 * N
		h = math.floor(N / 2)
		while h > 0:
			sum += 2 * h
			h = math.floor(h / 2)
		return sum


import math

class Solution:

	def jumpyBall(self, N):
		dists = [N, N]
		while dists[-1] >= 1:
			last_dist = dists[-1]
			new_h = math.floor(last_dist / 2)
			dists.append(new_h)
			dists.append(new_h)
		if dists[-1] < 1 and dists[-2] < 1:
			dists.pop(-1)
			dists.pop(-1)
		return sum(dists)


class Solution:

	def jumpyBall(self, N):
		one_side_dist = N
		while N > 0:
			one_side_dist += int(N / 2)
			N = int(N / 2)
		return one_side_dist * 2


import math

class Solution:

	def jumpyBall(self, N):
		if N == 0:
			return 0
		return N * 2 + self.jumpyBall(int(N / 2))


class Solution:

	def jumpyBall(self, N):
		if N == 0:
			return 0
		elif N == 1:
			return 2
		return 2 * N + self.jumpyBall(N // 2)