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: introductory

Starter code:

def am_i_wilson(n):
	

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

def am_i_wilson(n):
   #Piece of shit instead of code for piece of shit instead of instructions. 
   #It is really hard to imagine even worse exercise than this for 8 kyu.
   #Extreamly outdated for 2019 it no longer has place in here. 
    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]

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

"""from math import factorial, sqrt

def prime(n):
    if n % 2 == 0 and n > 2: 
        return False
    return all(n % i for i in range(3, int(sqrt(n)) + 1, 2))

def am_i_wilson(n):
    if not prime(n):
        return False
    elif:
        n == 0:
            return False
    else:
        square = n ** 2
        val = (factorial(n) + 1) / square
        if val > 0:
            return True
        else:
            return False
"""

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

# this is not 8 kyu, not programming, not even math.
# this is 'google it, then hardcode it'.
# leave this to neural nets, don't solve it in a browser.
def am_i_wilson(n):
    return n in [5, 13, 563]

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

def am_i_wilson(n):
    if n in (5,13,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):
    """ Check if given number is a wilson prime. """
    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):
    #your code here
    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


def am_i_wilson(n):
    if n == 5 or n == 563 or n == 13:
        return True 
    else:
        return 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)

import math
def am_i_wilson(n):
    return (n == 5) or (n == 13) or (n == 563)
    
    #would have used the following code, but the factorials become to large a number and it times out
    #print(n)
    #if n > 1:
    #    if ((math.factorial(n-1)) + 1) / (n * n) % 1 == 0:
    #        return(True)
    #    else:
    #        return(False)
    #else:
    #    return(False)


def am_i_wilson(n):
    return (n==13 or n== 5 or n == 563)
    #your code here


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()


#import math
def am_i_wilson(n):
    #Execution Timed Out
    #if n == 1 or n == 0:
        #return False
    #try:
        #my_fact = math.factorial(n-1)
        #res = ((my_fact) + 1) / n
        
        #if res == int(res):
            #return True
        #else:
            #return False
    #except:
        #return False

    return True if n == 5 or n == 13 or n ==563 else False

from math import factorial
def am_i_wilson(n):
#    print(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


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


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

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 n in [563,13,5]

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

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):
    #your code here
    return True if n > 1 and n < 1000 and (factorial((n-1)) + 1) % n**2 == 0 else False

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

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

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)

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

# def am_i_wilson(n):
#    #Piece of shit instead of code for piece of shit instead of instructions. 
#    #It is really hard to imagine even worse exercise than this for 8 kyu.
#    #Extreamly outdated for 2019 it no longer has place in here. 
#     return True if n == 5 or n == 13 or n == 563 else False

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


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
    #f = (factorial(n - 1) + 1) / (n * n)
    return str(n)

def am_i_wilson(n):
    print(n)
    return n == 5 or n == 13 or n == 563
#     print(n)
#     if n == 0:
#         return False
#     fct = 1
#     for i in range(1, n):
#         fct = fct * i
#     P = (fct+1) / (n*n)
#     return P == 1.0


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(n):
    x=[5,13,563]
    if n in x:
        return True
    else:
        return False

def am_i_wilson(P):
    #https://en.wikipedia.org/wiki/Wilson_prime
    if P == 5 or P == 13 or P == 563:
        return True
    else:
        return False


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

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:
        #print(fact(n-1))
        wp = ((fact(n-1) + 1) % (n*n))
    return True if wp == 0 else False
    


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

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


def am_i_wilson(n): return n==5 or n==13 or n==563 # this kata should be retired.

# from functools import reduce


def am_i_wilson(n):

    # print(((reduce(lambda a, b: a * b, list(range(1, n))) + 1) %
    #      (n ** 2)) == 0 if n > 2 else False)

    # This is the only way to do this kata, else it will say Timeout error LoL

    return(n in [5, 13, 563])

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(num):
    if num < 2 or not all(num % i for i in range(2, num)):
        return False
    return (math.factorial(num - 1) + 1) % (num ** 2) == 0

# import math
# def am_i_wilson(n):
#     n1 = math.ceil(math.sqrt(n))
#     c = 0
#     if n <= 1:
#         return False
#     for i in range(2, n1 + 1):
#         if n%i == 0:
#             c+= 1
#     if c != 0:
#         return False
#     x = (math.factorial(n-1)+1)/((n**2))

#     return x.is_integer()


# import math

# def am_i_wilson(n):
#     if n <= 2:
#         return False
#     fact=math.factorial(n-1)        
#     if (fact+1)%n==0:
#         if (fact+1)%(n**2)==0:
#             return True
#         return False
#     return False
    
def am_i_wilson(n):   
    return n in (5, 13, 563)

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(n):

    primes = [5,13,563]
    return n in primes

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

def am_i_wilson(P):
    return P in (5, 13, 563)
    # not by my zelf, just copy for one more punt.....


def am_i_wilson(n): ### This is idiotic... 
    if n in [5, 13, 563]:
        return True
    else:
        return False
"""
def is_prime(n):
    if n % 2 == 0 and n > 2: 
        return False
    for i in range(3, int(n**0.5) + 1, 2):
        if n % i == 0:
            return False
    return True  

def fac(n):
    count = 1
    for each in range(1, n + 1):
        print(count)
        count *= each
    return count

def am_i_wilson(n):
    print(n)
    if n in (0,1):
        return False
    if is_prime(n):
        tmp = (fac(n-1)+1)/(n**2)
        if tmp == int(tmp):
            return True
    else:
        return False 
"""

# from math import factorial
def am_i_wilson(n):
        return n in (5,13,563)
#         return (factorial(n-1) + 1) % (n * n) == 0 if n > 1 else False


'''import math
def am_i_wilson(n):
    if n > 0:
        x = (math.factorial(n - 1) + 1) / (n**2)
        return True if x == int(x) else False
    else: return False'''
    
def am_i_wilson(n):
    return True if n in (5, 13, 563) else False

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

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(n):
    # https://yanzhan.site/codewars/wilson-primes.html
    return n == 5 or n == 13 or n == 563

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
    # next wilson prime somewhere above 10**13, let's say close to 10**63


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


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

import math, sys
def am_i_wilson(n):
    return n in (5, 13, 563)


#import math
#from decimal import *
def am_i_wilson(n):
    #if n > 1:
    #    return (Decimal(math.factorial(n-1) + 1) / n**2) % 1 == 0
    #else: return False
    
    return n in [5,13,563]

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


def am_i_wilson(n):
    if n==5 or n==13 or n==563:
        return True
    else:
        return False
    '''
    if n <= 2:
        return False
    fact=math.factorial(n-1)
    if (fact+1)%n==0:
        x = (fact+1)%(n**2)
        if x==0:
            return True
        else:
            return False
    else:
        return False
    '''

import sys
sys.float_info.max
import math
#sys.setrecursionlimit(n)

def am_i_wilson(n):
    #sys.setrecursionlimit(100000)
    print(n)
    if n <= 1: return False
    if n > 1000:
        if n%2==0: #even
            return False
        else: # odd
            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

def am_i_wilson(n):
    #your code here
    if n == 5 or n==13 or n==563:
        return True
    else:
        return False 
          #5, 13, and 563


import sys

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


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 am_i_wilson(n):
#    if n < 2:
#        return False
#    elif n == 2:
#        return True
#    else:
#        if n%2 != 0:
#            for i in range(3,int(n**0.5)+1,2):   # only odd numbers
#                if n%i==0:
#                    return False
#            print (n)
#            print ("not feck")
#            return True
#        else:
#            for i in range(2,n):
#                if n%i==0:
#                    print (n)
#                    print ("feck")
#                    return False
#            print (n)
#            print ("not feck")
#            return True


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

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


from math import factorial
def am_i_wilson(n):
    if n in (5, 13, 563):
        return True
    return False

from math import factorial

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


# from math import sqrt, ceil

# def is_prime(n):
#     if n <= 1:
#         return False
#     else:
#         for i in range(2, ceil(sqrt(n)) + 1):
#             if n % i == 0:
#                 return False
#     return True

# def fact(x):
#     fact = 1
#     for i in range(1, x + 1):
#         fact *= i
#     return fact

def am_i_wilson(n):
#     if not is_prime(n):
#         return False
#     else:
#         return fact(n - 1) == -1 % (n * n)
    return n in [5, 13, 563, 5971, 558771, 1964215, 8121909, 12326713, 23025711, 26921605, 341569806, 399292158]