Given a number N. Check whether it is divisble by 4.
Example 1:
Input:
N = 1124
Output: 1
Explanation: The number is divisible by 4
as 1124 % 4 = 0.
Ã¢â¬â¹Example 2:
Input: 
N = 7
Output: 0
Explanation: The number is not divisibly by
4 as 7 % 4 = 3.
Your Task:
You don't need to read input or print anything. Your task is to complete the function divisibleBy4() which takes the number in the form of a string N as input and returns 1 if the number is divisible by 4. Else, it returns 0.
Expected Time Complexity: O(1).
Expected Auxiliary Space: O(1).
Constraints:
1 <= N <= 10^{1000}+5

Source: geeksforgeeks | Difficulty: EASY
Tags: String algorithms

Data structures

Mathematics

Starter code: #User function Template for python3
class Solution:
	def divisibleBy4 (self, N):
		# Your Code Here

Solutions:
class Solution:

	def divisibleBy4(self, N):
		if int(N) % 4 == 0:
			return 1
		else:
			return 0


class Solution:

	def divisibleBy4(self, N):
		if int(str(N)[-2:]) % 4 == 0:
			return 1
		return 0


class Solution:

	def divisibleBy4(self, N):
		N = int(N)
		return int(not N % 4)


class Solution:

	def divisibleBy4(self, N):
		result = int(N)
		ree = result % 4
		if ree == 0:
			return 1
		return 0


class Solution:

	def divisibleBy4(self, n):
		if int(n) % 4 == 0:
			return 1
		return 0


class Solution:

	def divisibleBy4(self, N):
		n = int(N[-2:])
		return int(not n % 4)


class Solution:

	def divisibleBy4(self, N):
		if len(N) <= 2:
			return 1 if int(N) % 4 == 0 else 0
		n = len(N)
		num = int(N[n - 2:n])
		return 1 if num % 4 == 0 else 0