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. If n < 0 the function should return False

from math import factorial def wilson_primes(p): if (factorial(p-1)+1)%(p*p) == 0 and p>1: return True return False

Questions about programming?Chat with your personal AI assistant