Advertisement
paulogp

Primos

Aug 7th, 2011
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. #!/usr/bin/python3
  2. # paulogp
  3. # prime numbers
  4.  
  5. def is_prime(the_n):
  6.     if (the_n == 1):
  7.         print("1 is special")
  8.         return False
  9.    
  10.     for the_x in range(2, the_n):
  11.         if (the_n % the_x == 0):
  12.             print("{} equals {} x {}".format(the_n, the_x, the_n // the_x))
  13.             return False
  14.     else:
  15.         print("{} is a prime number".format(the_n))
  16.         return True
  17.  
  18. # first 30 numbers
  19. for the_n in range(1, 30):
  20.     is_prime(the_n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement