Primality by Wilson's theorem: Difference between revisions

m
→‎{{header|Python}}: polish the code a bit
m (→‎{{header|Python}}: polish the code a bit)
Line 1,456:
 
def is_wprime(n):
return n > 1 and bool(n == 2 or (
n > 1
(n % 2 and (factorial(n - 1) + 1) % n == 0))
and n % 2 != 0
(n % 2 and (factorial(n - 1) + 1) % n == 0))
)
 
if __name__ == '__main__':
c = int(input('Enter upper limit: '))
c = 100
print(f"'Primes under {c}:", end='\n ')
print([n for n in range(c) if is_wprime(n)])</lang>