Given a number N. The task is to check if N is woodall number or not. A Woodall Number is of the form:
W_{n} = n.2^{n} – 1
The first few Woodall numbers are: 1, 7, 23, 63, 159, 383, 895……
Example 1:
Input: N = 383
Output: 1
Explaination: 6*2^{6} - 1 = 383.
Example 2:
Input: N = 200
Output: 0
Explaination: This is not a Woodall number.
Your task:
You do not need to read input or print anything. Your task is to complete the function isWoodall() which takes N as input parameter and returns 1 if it is a Woodall number, else returns 0.
Expected Time Complexity: O(logN)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 10^{6}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def isWoodall(self, N):

        # code here

Solutions:
class Solution:

	def isWoodall(self, N):
		(tem, c) = (N + 1, 0)
		while tem % 2 == 0 and c < tem:
			tem = tem // 2
			c += 1
		if c == tem:
			return 1
		return 0


class Solution:

	def isWoodall(self, N):
		for i in range(1, int(N ** 0.5) + 1):
			if i * 2 ** i == N + 1:
				return 1
		return 0


import math

class Solution:

	def isWoodall(self, N):
		l = []
		for i in range(1, int(N ** 0.5)):
			l.append(i * pow(2, i) - 1)
		if N in l:
			return 1
		else:
			return 0
		return l


class Solution:

	def isWoodall(self, N):
		for i in range(1, N + 1):
			current = i * 2 ** i - 1
			if current == N:
				return 1
			elif current > N:
				return 0


class Solution:

	def isWoodall(self, N):
		current = 0
		n = 1
		while current < N:
			current = n * 2 ** n - 1
			if current == N:
				return 1
			n += 1
		return 0


class Solution:

	def isWoodall(self, N):
		for n in range(20):
			num = n * 2 ** n - 1
			if num == N:
				return 1
		else:
			return 0


class Solution:

	def isWoodall(self, N):
		Wn = 0
		for i in range(1, N):
			if Wn <= N:
				Wn = i * pow(2, i) - 1
				if Wn == N:
					return 1
		return 0


class Solution:

	def isWoodall(self, N):
		x = i = 0
		while x <= N:
			x = i * 2 ** i - 1
			if x == N:
				return 1
			i += 1
		return 0


class Solution:

	def isWoodall(self, N):
		result = 0
		for i in range(1, N):
			res = i * pow(2, i) - 1
			if res > N:
				break
			elif res == N:
				result = 1
				break
		if result == 1:
			return 1
		else:
			return 0


class Solution:

	def isWoodall(self, N):
		p = 2
		q = N + 1
		c = 1
		while p <= N:
			if q % p == 0 and q // p == c:
				return 1
			c += 1
			p = p * 2
		return 0


class Solution:

	def isWoodall(self, N):
		for x in range(1, 2000):
			y = x * 2 ** x - 1
			if y == N:
				return 1
			elif y > N:
				return 0


class Solution:

	def isWoodall(self, N):
		num1 = 1
		for i in range(0, N // 2):
			num1 = i * 2 ** i - 1
			if num1 == N:
				return 1
			elif num1 > N:
				return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isWoodall(N))


class Solution:

	def isWoodall(self, N):
		n = 1
		while n * 2 ** n - 1 <= N:
			if n * 2 ** n - 1 == N:
				return 1
			n += 1
		return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.isWoodall(N))


class Solution:

	def isWoodall(self, N):
		i = 1
		while i:
			n = i * 2 ** i - 1
			if n == N:
				return 1
			elif n > N:
				return 0
			else:
				i += 1


class Solution:

	def isWoodall(self, N):
		for i in range(20):
			W = i * 2 ** i - 1
			if W == N:
				return 1
		return 0


from math import sqrt
from math import ceil

class Solution:

	def isWoodall(self, N):
		if N == 1:
			return 1
		for i in range(2, int(ceil(sqrt(N)))):
			if N + 1 == i * 2 ** i:
				return 1
		return 0


class Solution:

	def isWoodall(self, N):
		w = n = 1
		while w <= N:
			if w == N:
				return 1
			w = n * pow(2, n) - 1
			n += 1
		return 0


class Solution:

	def isWoodall(self, N):
		for x in range(N // 2):
			if x * pow(2, x) - 1 == N:
				return 1
		return 0


class Solution:

	def isWoodall(self, N):
		i = 1
		while True:
			s = i * pow(2, i) - 1
			if s == N:
				return 1
			elif s > N:
				return 0
			i += 1


class Solution:

	def isWoodall(self, N):
		l = [0]
		i = 1
		while N > max(l):
			l.append(i * pow(2, i) - 1)
			if N == max(l):
				break
			i += 1
		if N == l[-1]:
			return 1
		else:
			return 0


class Solution:

	def isWoodall(self, N):
		for i in range(1, N):
			res = i * 2 ** i - 1
			if res == N:
				return '1'
				break
			if res > N:
				return '0'
				break


class Solution:

	def isWoodall(self, N):
		for i in range(1, 1001):
			if i * 2 ** i - 1 == N:
				return 1
		return 0


class Solution:

	def isWoodall(self, N):
		ans = 1
		c = 2
		while ans <= N:
			if ans == N:
				return 1
			ans = c * 2 ** c - 1
			c += 1
		return 0