Generation

generate functionThu, 22 Dec 2022

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.

def am_i_wilson(n): from math import factorial return factorial(n-1)+1 == n*n*factorial(n-2)

Want to kickstart your project?Use the new AI Studio to create your code