Given two values N and M. Give the value when N is halved M-1 times.
Example 1:
Input: N = 100, M = 4
Output: 12
Explaination: The sequence of numbers is 
100, 50, 25, 12.
Example 2:
Input: N = 10, M = 5
Output: 0
Explaination: The sequence is 10, 5, 2, 1 and 0.
Your Task:
You do not need to read input or print anything. Your task is to complete the function mthHalf() which takes N and M as input  parameters and retunrs the value of N when it is halved M-1 times.
Expected Time Complexity: O(log(max(N, M)))
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 10^{9}
1 ≤ M ≤ 1000

Difficulty: EASY
Tags: Mathematics
Expected Time Complexity: O(log(max(N, M)))
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

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

Solutions:
import math

class Solution:

	def mthHalf(self, N, M):
		return math.trunc(N / 2 ** (M - 1))


class Solution:

	def mthHalf(self, N, M):
		for i in range(M - 1):
			N = N // 2
		return N


class Solution:

	def mthHalf(self, N, M):
		while M != 1:
			N = N // 2
			M -= 1
		return N


import math

class Solution:

	def mthHalf(self, N, M):
		ans = -1
		while M > 0:
			ans = N
			N = N // 2
			M -= 1
		return ans


class Solution:

	def mthHalf(self, N, M):
		for i in range(M - 1):
			if N != 0:
				N //= 2
			else:
				return 0
		return N


class Solution:

	def mthHalf(self, N, M):
		sum = 0
		while M != 1:
			sum = N // 2
			N = sum
			M -= 1
		if M == 1:
			return N
		return sum


class Solution:

	def mthHalf(self, N, M):
		return N >> M - 1


class Solution:

	def mthHalf(self, N, M):
		l = []
		l.append(N)
		for i in range(M - 1):
			ans = N // 2
			l.append(ans)
			N = ans
		return l[-1]


class Solution:

	def mthHalf(self, N, M):
		lst = []
		lst.append(N)
		for i in range(M):
			c = lst[i] // 2
			lst.append(c)
		return lst[M - 1]


class Solution:

	def mthHalf(self, N, M):
		li = [N]
		while len(li) < M:
			N = N // 2
			li.append(N)
		return li[M - 1]


class Solution:

	def mthHalf(self, N, M):
		(num, den) = (N, 2 ** (M - 1))
		return num // den


class Solution:

	def mthHalf(self, N, M):
		ans = N
		for i in range(M - 1):
			ans = ans // 2
			if ans == 0:
				return ans
				break
		return ans


class Solution:

	def mthHalf(self, N, M):
		i = 0
		while i < M - 1:
			N = N // 2
			i += 1
		return N


class Solution:

	def mthHalf(self, N, M):
		x = 2 ** (M - 1)
		if x > N:
			return 0
		return int(N // x)


class Solution:

	def mthHalf(self, N, M):
		for _ in range(M - 1):
			N /= 2
		return int(N)


class Solution:

	def mthHalf(self, N, M):
		if M == 1:
			return N
		while M > 1:
			x = N // 2
			N = x
			M -= 1
		return x


class Solution:

	def mthHalf(self, N, M):
		a = [N]
		for i in range(M - 1):
			N = int(N / 2)
			a.append(N)
		return a[-1]


import math

class Solution:

	def mthHalf(self, N, M):
		for x in range(M - 1):
			N /= 2
		return math.floor(N)


class Solution:

	def mthHalf(self, N, M):
		count = 1
		while count < M:
			N = N >> 1
			count += 1
		return N


class Solution:

	def mthHalf(self, N, M):
		k = N
		a = []
		for i in range(M):
			N //= 2
			a.append(N)
		a.remove(a[-1])
		a.append(k)
		a.sort(reverse=True)
		return a[-1]


class Solution:

	def mthHalf(self, n, m):
		while m != 1:
			n = n // 2
			m -= 1
		return n


class Solution:

	def mthHalf(self, N, M):
		s = N // 2 ** (M - 1)
		return s


class Solution:

	def mthHalf(self, n, m):
		x = n
		for i in range(1, m):
			x //= 2
		return x


import math

class Solution:

	def mthHalf(self, N, M):
		p = 0.5 ** (M - 1)
		q = p * N
		return math.floor(q)