Check the given number is prime or not using JAVA regex.
Example 1:
Input: N = 5
Output: 1
Explanation: 5 is prime number.
Example 2:
Input: N = 10
Output: 0
Explanation: 10 is not prime number.
 
Your Task:
You don't need to read or print anyhting.  Your task is to complete the function isPrime() which takes N as input parameter and returns 1 if N is prime otherwise returns 0.
 
Expected Time Complexity: O(N/2)
Expected Space Complexity: O(1)
 
Constraints:
1 <= N <= 10000

Source: geeksforgeeks | Difficulty: EASY

Starter code: #User function Template for python3

class Solution:
	def isPrime(self, N):
		# Code here

Solutions:
class Solution:

	def isPrime(self, N):
		if N == 1:
			return 0
		for i in range(2, N // 2 + 1):
			if N % i == 0:
				return 0
		else:
			return 1


import re

class Solution:

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


import math

class Solution:

	def checkPrime(self, n):
		if n <= 1:
			return False
		max_div = math.floor(math.sqrt(n))
		for i in range(2, max_div + 1):
			if n % i == 0:
				return False
		return True

	def isPrime(self, N):
		if self.checkPrime(N):
			return 1
		else:
			return 0
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		N = int(input())
		ob = Solution()
		ans = ob.isPrime(N)
		print(ans)


class Solution:

	def isPrime(self, N):
		if N == 1:
			return 0
		else:
			sqrt = N ** 0.5
			for i in range(2, int(sqrt) + 1):
				if N % i == 0:
					return 0
		return 1
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		N = int(input())
		ob = Solution()
		ans = ob.isPrime(N)
		print(ans)


import numpy

class Solution:

	def isPrime(self, N):
		if N == 1:
			return 0
		else:
			for i in range(2, int(numpy.sqrt(N)) + 1):
				if N % i == 0:
					return 0
		return 1


class Solution:

	def isPrime(self, N):
		if N == 1:
			return 0
		if N == 2 or (N != 2 and N % 2 != 0 and (len([x for x in range(3, int(N ** 0.5) + 1, 2) if N % x == 0]) == 0)):
			return 1
		return 0


import math

class Solution:

	def isPrime(self, N):
		if N == 0 or N == 1:
			return 0
		for i in range(2, int(math.sqrt(N) + 1), 1):
			if N % i == 0:
				return 0
		return 1


class Solution:

	def isPrime(self, N):
		m = N / 2 + 1
		if N > 1:
			for i in range(2, int(m)):
				if N % i == 0:
					return 0
					break
			else:
				return 1
		else:
			return 0


import re

class Solution:

	def isPrime(self, n):
		return int(not re.match('^.?$|^(..+?)\\1+$', '1' * n))


import math

class Solution:

	def isPrime(self, N):
		if N == 1:
			return 0
		is_prime = True
		for n in range(2, round(math.sqrt(N)) + 1):
			if N % n == 0:
				is_prime = False
		if is_prime:
			return 1
		else:
			return 0


class Solution:

	def isPrime(self, N):
		if N == 1:
			return 0
		is_prime = True
		for n in range(2, N // 2 + 1):
			if N % n == 0:
				is_prime = False
		if is_prime:
			return 1
		else:
			return 0