brilliant_moves

PrimeFactorials.py

Feb 3rd, 2016
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. '''
  2. write a python factorial program for prime numbers between 0-100.
  3. '''
  4.  
  5. def isPrime(n):
  6.     if n<2: return False
  7.        
  8.     for i in range(2, n):
  9.         if n%i==0: return False
  10.  
  11.     return True
  12.  
  13.  
  14. def fact(number):
  15.     factorial = 1
  16.     while number>=1:
  17.         factorial *= number
  18.         number -= 1
  19.     return factorial
  20.  
  21.  
  22. def main():
  23.     print ("Prime Factorial")
  24.     for z in range (0, 100):
  25.         if isPrime (z):
  26.             print (z, fact (z))
  27.  
  28.  
  29. main()
Advertisement
Add Comment
Please, Sign In to add comment