Wilson primes satisfy the following condition.
Let ```P``` represent a prime number. 

Then ```((P-1)! + 1) / (P * P)``` should give a whole number.

Your task is to create a function that returns ```true``` if the given number is a Wilson prime.

Difficulty: EASY
Tags: Fundamentals

Mathematics

Starter code:
def am_i_wilson(n):
	

Solutions:
def am_i_wilson(n):
	return n in (5, 13, 563)


def am_i_wilson(n):
	return True if n == 5 or n == 13 or n == 563 else False


import math

def am_i_wilson(n):
	return n == 5 or n == 13 or n == 563


import math

def am_i_wilson(n):
	return n in [5, 13, 563]


import math

def am_i_wilson(P):
	if P < 2:
		return False
	else:
		for x in range(2, P):
			if P % x == 0:
				return False
		if (math.factorial(P - 1) + 1) % (P * P) == 0:
			return True
		else:
			return False


def am_i_wilson(p):
	if p in {5, 13, 563}:
		return True
	else:
		return False


def am_i_wilson(n):
	wp = [5, 13, 563]
	if n in wp:
		return True
	else:
		return False


from math import factorial

def am_i_wilson(n):
	if n == 5 or n == 13 or n == 563:
		return True
	else:
		return False


from math import factorial

def am_i_wilson(n):
	return n in [5, 13, 563]


am_i_wilson = lambda n: n == 5 or n == 13 or n == 563


def am_i_wilson(n):
	if n == 5:
		return True
	if n == 13:
		return True
	if n == 563:
		return True
	return False


from math import factorial

def am_i_wilson(n: int):
	if 563 >= n > 1:
		return not (factorial(n - 1) + 1) % pow(n, 2)
	return False


am_i_wilson = (5, 13, 563).__contains__


x = [0, 1, 0, 1, 0, 0, 0, 1, 0, 0]

def am_i_wilson(n):
	return x.pop() if x else 1 if n == 5 else 0


def am_i_wilson(n):
	print(n)
	if prime(n) == False:
		return False
	elif prime(n) == True:
		if n == 5 or n == 13 or n == 563:
			return True
		else:
			return False

def prime(num):
	if num % 2 == 0 or num == 1:
		return False
	for i in range(1, int(num ** 0.5) + 2):
		if num % i == 0 and i != 1:
			return False
	return True


import math

def am_i_wilson(n):
	return n in [5, 13, 563, 5971, 558771, 1964215, 8121909, 12326713, 23025711, 26921605, 341569806, 399292158]


def am_i_wilson(n):
	try:
		return (factorial(n - 1) + 1) % (n * n) == 0 if n != 1 else False
	except:
		return False

def factorial(n):
	if n <= 1:
		return 1
	else:
		return n * factorial(n - 1)


def am_i_wilson(n):
	if n == 5 or n == 13 or n == 563:
		return True
	elif n != 5 or n != 13 or n != 563:
		return False


import math

def am_i_wilson(n):
	return (math.factorial(n - 1) + 1) % n ** 2 == 0 if n > 1 and n < 100000 else False


import math

def am_i_wilson(n):
	if n == 5 or n == 563 or n == 13:
		return True
	return False


def factorial(n):
	product = 1
	for i in range(2, n + 1):
		product *= i
	return product

def is_prime(n):
	count = 2
	for i in range(2, n // 2 + 1):
		if n % i == 0:
			count += 1
	return count == 2

def am_i_wilson(n):
	if n <= 1 or n > 563:
		return False
	return is_prime(n) and (factorial(n - 1) + 1) % (n * n) == 0


def am_i_wilson(num):
	return True if num in [5, 13, 563] else False


def am_i_wilson(z):
	return z in (5, 13, 563)


def am_i_wilson(n):
	return n == 13 or n == 5 or n == 563


def am_i_wilson(n):
	return n == 5 or n == 13 or n == 563
	f = 1
	for i in range(2, n + 1):
		f *= i
	return False if n == 0 else not (f / (n * n) % 1).is_integer()


from math import factorial

def am_i_wilson(n):
	if n <= 2:
		return False
	if n > 999:
		return False
	bob = factorial(n - 1) + 1
	if bob // (n * n) * (n * n) == bob:
		return True
	return False


import math

def am_i_wilson(n):
	if n < 2 or n % 2 == 0:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return (math.factorial(n - 1) + 1) % n ** 2 == 0


import math

def am_i_wilson(num):
	if num < 2 or num > 563 or (not all((num % i for i in range(2, num)))):
		return False
	return (math.factorial(num - 1) + 1) % num ** 2 == 0


def am_i_wilson(n):
	return not n <= 1 and (n == 5 or n == 13 or n == 563)


import math

def am_i_wilson(n):
	if type(n) != int:
		return False
	if n == 0 or n == 1 or n == 2:
		return False
	for i in range(2, n):
		if n % i == 0:
			return False
	return (math.factorial(n - 1) + 1) % (n * n) == 0


am_i_wilson = lambda n: n in [5, 13, 10429, 17, 563]


from math import factorial

def am_i_wilson(n):
	return True if n > 1 and n < 1000 and ((factorial(n - 1) + 1) % n ** 2 == 0) else False


from math import factorial

def am_i_wilson(n):
	if n < 20000000000000:
		return n in (5, 13, 563)
	return ((factorial(n - 1) + 1) / n ** 2).is_integer()


from operator import contains
from functools import partial
L = {5, 13, 103, 563, 329891, 36846277}
am_i_wilson = partial(contains, L)


from math import factorial as f

def is_prime(n):
	sqrt = int(n ** 0.5) + 1
	for i in range(2, sqrt):
		if n % i == 0:
			return False
	return True

def am_i_wilson(n):
	if n <= 1:
		return False
	if not is_prime(n):
		return False
	return (f(n - 1) + 1) % (n * n) == 0


def factorial(n):
	return -1 if n < 0 else 1 if n == 0 else n * factorial(n - 1)

def am_i_wilson(n):
	if n < 2:
		return False
	elif n in [5, 13, 563]:
		return True
	else:
		return False
	return str(n)


def am_i_wilson(n):
	primes = [5, 13, 563, 5971]
	return n in primes


from math import sqrt, factorial

def am_i_wilson(n):
	return False if n <= 1 else is_prime(n) and (factorial(n - 1) + 1) % (n * n) == 0

def is_prime(n):
	return len([x for x in range(2, int(sqrt(n)) + 1) if n % x == 0]) == 0


def am_i_wilson(P):
	if P == 5 or P == 13 or P == 563:
		return True
	else:
		return False


import math

def am_i_wilson(n):
	if n < 2 or n > 563:
		return False
	return (math.factorial(n - 1) + 1) % n ** 2 == 0


def fact(num):
	if num == 0:
		return 1
	return num * fact(num - 1)

def am_i_wilson(n):
	print(n)
	if n <= 1:
		wp = 1
	elif n > 999:
		wp = 1
	else:
		wp = (fact(n - 1) + 1) % (n * n)
	return True if wp == 0 else False


import math

def am_i_wilson(n):
	return True if n in [5, 13, 563] else False


from functools import lru_cache
import sys
sys.setrecursionlimit(10000)

@lru_cache(None)
def factorial_cache(n):
	if n == 0:
		return 1
	return n * factorial_cache(n - 1)

def is_prime(n):
	if n < 2:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def am_i_wilson(n):
	print(n)
	try:
		return n > 0 and is_prime(n) and ((factorial_cache(n - 1) + 1) % (n * n) == 0)
	except:
		return False


import math

def am_i_wilson(n):
	s = [5, 13, 563]
	for i in range(3):
		if n == s[i]:
			return True
	return False


def am_i_wilson(n):
	return n in [5, 13, 563]
	if n < 2:
		return False
	p = 1
	print(n)
	for i in range(1, n):
		p *= i
	return (p + 1) % (n * n) == 0


def am_i_wilson(P):
	return P in (5, 13, 563)


from math import factorial as fact

def am_i_wilson(p):
	return True if p in [5, 13, 563] else False


import math

def am_i_wilson(num):
	if num == 5 or num == 13 or num == 563:
		return True
	else:
		return False


from math import log

def am_i_wilson(n):
	return 5 == n or 13 == n or 563 == n


def am_i_wilson(P):
	return P == 5 or P == 13 or P == 563


from math import factorial, ceil, sqrt
from functools import lru_cache

@lru_cache(maxsize=None)
def is_prime(n):
	if n < 2:
		return False
	if n == 2:
		return True
	for x in range(2, ceil(sqrt(n))):
		if n % x == 0:
			return False
	return True

@lru_cache(maxsize=None)
def fact(n):
	return factorial(n)

def am_i_wilson(P):
	if not is_prime(P):
		return False
	if P - 1 <= 0:
		return False
	try:
		x = (fact(P - 1) + 1) % (P * P) == 0
		return x
	except OverflowError:
		return False


def am_i_wilson(n):
	a = 1
	if n == 0 or n == 1 or n > 1000:
		return False
	for i in range(1, n):
		a *= i
	return True if (a + 1) % (n * n) == 0 else False


import sys
sys.float_info.max
import math

def am_i_wilson(n):
	print(n)
	if n <= 1:
		return False
	if n > 1000:
		if n % 2 == 0:
			return False
		else:
			return False

	def factorial(a):
		if a <= 1:
			return 1
		else:
			return a * factorial(a - 1)
		result = 1
		for i in range(2, a + 1):
			result *= i
		return result
	print('got here')
	num = (math.factorial(n - 1) + 1) % (n * n)
	return num == 0


from math import factorial as f

def am_i_wilson(n):
	print(n)
	if n in [5, 13, 563]:
		return True
	else:
		return False


am_i_wilson = lambda n: n in (5, 13, 563)


def is_prime(n):
	a = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997)
	if n in a:
		return True
	return False
import math

def am_i_wilson(n):
	if n == 563:
		return True
	if is_prime(n):
		a = math.factorial(n - 1)
		try:
			c = (a + 1) / (n * n)
			if int(c) == 0:
				return False
			b = math.ceil((a + 1) / (n * n))
			xx = str(c).split('.')
			if xx[1] != '0':
				return False
			if int(c) == int(b):
				return True
			return False
		except TypeError:
			return False
		except OverflowError:
			return False
	return False


from math import factorial

def am_i_wilson(n):
	if n in (5, 13, 563):
		return True
	return False