Find the Nth term of the following series :
N    Nth term
1    0
2    1
3    0
4    2
5    0
6    1
7    0
8    3
9    0
10    1
and so on.......
Example 1:
Input: N = 8
Output: 3 
Explanation: According to the series
for N = 8 Nth term is 3.
Example 2:
Input: N = 5
Output: 0
Explanation: According to the series
for N = 5 Nth term is 0.
Your Task:  
You dont need to read input or print anything. Complete the function findNth() which takes N as input parameter and returns the Nth term.
Expected Time Complexity: O(logn)
Expected Auxiliary Space: O(1)
Constraints:
1<= N <=10^{9}

Source: geeksforgeeks | Difficulty: EASY
Tags: Bit manipulation

Data structures

Starter code: #User function Template for python3
class Solution:
    def findNth (ob, n):
        # code here 

Solutions:
class Solution:

	def findNth(ob, n):
		ans = 0
		while n:
			if n & 1:
				return ans
			else:
				ans += 1
				n >>= 1
		return -1


import math

class Solution:

	def findNth(ob, n):
		if n & 1 == 1:
			return 0
		v = n & ~(n - 1)
		c = math.floor(math.log(v, 2))
		return c


from math import log

class Solution:

	def findNth(ob, n):
		num = bin(n)[2:]
		count = 0
		while num[-1] == '0':
			count += 1
			num = num[:-1]
		return count


class Solution:

	def findNth(ob, n):
		if n % 2 == 1:
			return 0
		elif n % 2 == 0:
			i = 0
			while n >= 2:
				i = i + 1
				n = n / 2
				if n % 2 == 1:
					break
			return i


import math

class Solution:

	def findNth(ob, n):
		if n & 1 == 1:
			return 0
		count = 0
		while n & 1 == 0:
			count += 1
			n = n >> 1
		return count


import math

class Solution:

	def findNth(ob, n):
		bits = math.floor(math.log(n, 2))
		if n & 1 == 1:
			return 0
		count = 0
		while n & 1 == 0:
			count += 1
			n = n >> 1
		return count


import math

class Solution:

	def findNth(ob, n):
		if n & 1 == 1:
			return 0
		val = n & ~(n - 1)
		count = math.floor(math.log2(val))
		return count


class Solution:

	def findNth(ob, n):
		c = 0
		while n % 2 == 0:
			c += 1
			n = n // 2
		return c


import math

class Solution:

	def findNth(ob, n):
		if n & 1 == 1:
			return 0
		val = n & ~(n - 1)
		count = math.floor(math.log(val, 2))
		return count


import math

class Solution:

	def findNth(ob, n):
		k = '0'
		count = 0
		st = bin(n)[2:]
		st2 = st[::-1]
		while k != '1':
			if st2[count] == '1':
				k = '1'
			else:
				count += 1
		return count


class Solution:

	def findNth(ob, n):
		if n % 2 != 0:
			return 0
		else:
			count = 0
			while n % 2 == 0:
				n /= 2
				count += 1
			return count