ده طريقة لكشف عن الرقم أنه أولي أم لا
#!/usr/bin/env python
import sys
sys.setrecursionlimit(100000)
#x must be bigger than 5
def fact(x):
if x==1:
return 1
else:
return x*fact(x-1)
print "Please enter a number to check if it a prime or not"
x=raw_input()
x=int(x)
if (fact(x-1) % x) != 0:
print x,"is a prime number"
else:
print x,"is not a prime number"هذا هو من أبطأ خوارزميات معروفة للكشف عن الأرقام الأولية.