A frog starts at the point 0. In his first turn, he can make a jump of 1 unit. Now for all consequent turns, if the frog is currently at a distance x (from the start), his jump will take him x units forward. Given a leaf at a distance N, you have to find if the frog can reach that leaf or not.
 
Example 1:
Input:
N = 3
Output:
False
Explanation:
The frog can't reach the position 3.
Example 2:
Input:
N = 2
Output:
True
Explanation:
The frog will jump to position 1 in
the first jump. Now, he is at a distance
of 1 from the start, so he cam jump 1m.
So, he reaches the point 2.
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function canJump() which takes an Integer N as input and return "True" if the frog can reach N else return "False".
 
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
 
Constraints:
1 <= N <= 10^{18}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3

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

Solutions:
class Solution:

	def canJump(self, N):
		if N == 1:
			return True
		if N % 2 == 1:
			return False
		else:
			while N > 2:
				N = N / 2
				if N % 2 == 1:
					return False
					break
			if N == 2:
				return True


class Solution:

	def canJump(self, N):
		prev = 1
		while prev <= N:
			if prev == N:
				return True
			prev += prev
		return False


class Solution:

	def canJump(self, n):
		if n & n - 1 == 0:
			return True
		else:
			return False


class Solution:

	def canJump(self, N):
		if N & N - 1 == 0:
			return 'True'
		return 'False'


class Solution:

	def canJump(self, N):
		i = 0
		a = 2 ** i
		while a < N:
			i += 1
			a = 2 ** i
		return a == N


class Solution:

	def canJump(self, N):
		return not N & N - 1


class Solution:

	def canJump(self, N):
		distance = 0
		while distance <= N:
			if distance == 0 or distance == 1:
				distance += 1
			else:
				distance *= 2
			if distance == N:
				return True
		return False


import math

class Solution:

	def canJump(self, N):
		num = int(math.log(N, 2))
		if 2 ** num == N:
			return 'True'
		else:
			return 'False'


class Solution:

	def canJump(self, n):
		return not n & n - 1


class Solution:

	def canJump(self, N):
		if N == 1 or (N and (not N & N - 1)) is True:
			return True
		return False


class Solution:

	def canJump(self, N):
		return N & N - 1 == 0


class Solution:

	def canJump(self, N):
		if N == 1 or N == 2:
			return True
		b = 2
		while b < N:
			b += b
		if b == N:
			return True
		else:
			return False


class Solution:

	def canJump(self, N):
		while True:
			if N == 1:
				return True
			elif N % 2 == 0:
				N = N // 2
			else:
				return False


class Solution:

	def canJump(self, N):
		return bin(N).count('1') == 1


class Solution:

	def canJump(self, N):
		jump_dist = 1
		dist = 0
		incr = 0
		while dist < N:
			dist += jump_dist
			if dist == N:
				return True
			jump_dist = dist
		return False


class Solution:

	def canJump(self, N):
		res = 0
		while pow(2, res) <= N:
			if pow(2, res) == N:
				return 'True'
			res += 1
		return False


class Solution:

	def canJump(self, n):
		k = 1
		while k <= n:
			if k == n:
				return True
			k = k * 2
		return False


class Solution:

	def canJump(self, N):
		j = 1
		while j <= N:
			if j == N:
				return True
			j = 2 * j
		return False


class Solution:

	def canJump(self, N):
		current = 1
		prev = 0
		result = False
		while prev <= N:
			if prev == N:
				result = True
			prev += current
			current = prev
		return result


class Solution:

	def canJump(self, x):
		if x == 1 or (x and (not x & x - 1)) is True:
			return True
		else:
			return False


import math

class Solution:

	def canJump(self, N):
		if math.log(N, 2).is_integer():
			return True
		return False


class Solution:

	def canJump(self, N):

		def possible(curr, prev):
			if curr == N:
				return True
			if curr > N:
				return False
			if prev == 0:
				return possible(curr + 1, 1)
			else:
				return possible(curr + prev, curr + prev)
		return possible(0, 0)


import math

class Solution:

	def canJump(self, N):
		return math.log(int(N), 2).is_integer()


class Solution:

	def canJump(self, N):
		if N == 1:
			return True
		Flag = False
		curr = 1
		while curr < N:
			curr += curr
		if curr == N:
			Flag = True
		return Flag


class Solution:

	def canJump(self, N):
		if N == 1:
			return True
		c_jump = 1
		jump = 0
		while jump < N:
			jump = jump + c_jump
			c_jump = jump
		if jump == N:
			return True
		else:
			return False


class Solution:

	def canJump(self, N):
		count = 0
		step = 1
		while count < N:
			count += step
			step = count
			if count == N:
				return True
		return False


class Solution:

	def canJump(self, N):
		if N == 0 or N == 1:
			return True
		while N > 1:
			if N % 2 == 1:
				return False
			N //= 2
		return True
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.canJump(N))


class Solution:

	def canJump(self, N):
		frog = 0
		while True:
			if frog == 0:
				frog += 1
			elif frog < N:
				frog += frog
			else:
				break
		if frog == N:
			return True
		else:
			return False
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.canJump(N))


import math

class Solution:

	def canJump(self, N):
		a = int(math.log2(N))
		if 2 ** a == N:
			return True
		else:
			return False
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.canJump(N))


import math

class Solution:

	def canJump(self, N):
		if N == 0:
			return true
		n = math.log2(N)
		if n == int(n):
			return True
		return False


import math

class Solution:

	def canJump(self, N):
		if N & N - 1 == 0:
			return True
		else:
			return False


class Solution:

	def canReach(self, n, i):
		if i == n:
			return True
		elif i > n:
			return False
		return self.canReach(n, i + i)

	def canJump(self, N):
		if N == 0:
			return True
		i = 1
		return self.canReach(N, i)


class Solution:

	def canJump(self, N):
		for i in range(100):
			n = pow(2, i)
			if n == N:
				return 'True'
		return 'False'


import math

class Solution:

	def canJump(self, N):
		x = math.log(N, 2)
		if pow(2, int(x)) == N or N == 1:
			return True
		else:
			return False


class Solution:

	def canJump(self, N):
		if N == 0:
			return True
		if N == 1:
			return True
		ans = 1
		for i in range(1, N):
			ans = ans * 2
			if ans == N:
				return True
			if ans > N:
				return False
		return False


class Solution:

	def canJump(self, N):
		x = 0
		i = 1
		while x < N:
			x += i
			i = x
		if x == N:
			return True
		return False


class Solution:

	def canJump(self, N):
		position = 0
		num = N
		flag = 0
		while position <= num:
			if position == num:
				flag = 1
			if position == 0:
				position = position + 1
			else:
				position = 2 * position
		if flag == 0:
			return False
		else:
			return True


class Solution:

	def canJump(self, N):
		s = 0
		a = False
		i = 1
		while i <= N:
			if i == N:
				a = True
				break
			else:
				i = i * 2
		return a


class Solution:

	def canJump(self, N):
		n = N
		return n == 0 or n & n - 1 == 0


class Solution:

	def canJump(self, N):
		cj = 1
		j = 0
		while j < N:
			j = j + cj
			cj = j
		if j == N:
			return 'True'
		return 'False'


class Solution:

	def canJump(self, N):

		def isposs(n, N):
			if n == N:
				return True
			if n > N:
				return False
			return isposs(2 * n, N)
		return isposs(1, N)


class Solution:

	def canJump(self, N):
		curr_jump = 1
		jump = 0
		while jump < N:
			jump += curr_jump
			curr_jump = jump
		return jump == N


class Solution:

	def canJump(self, N):
		if N == 0 or N == 1:
			return True
		elif not N & N - 1:
			return True
		else:
			return False


import math

class Solution:

	def canJump(self, N):
		x = math.log(N) / math.log(2)
		if 2 ** x == 2 ** int(x):
			return True
		return False


import math

class Solution:

	def canJump(self, N):
		if N == 0 or N == 1:
			return 'True'
		res = math.log2(N)
		if int(res) == res:
			return 'True'
		return 'False'