annotate python/prime.py @ 251:c37750a70f94

no need for subversion config anymore
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 04 Dec 2012 11:02:45 -0800
parents 05728a85e19b
children 8593b0384d3e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
238
05728a85e19b add prime.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/usr/bin/env python
05728a85e19b add prime.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
05728a85e19b add prime.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 def prime(number):
05728a85e19b add prime.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 half = int(number / 2)
05728a85e19b add prime.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 for i in range(2, half):
05728a85e19b add prime.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 if not number % i:
05728a85e19b add prime.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 return False
05728a85e19b add prime.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 return True
05728a85e19b add prime.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9
05728a85e19b add prime.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 if __name__ == '__main__':
05728a85e19b add prime.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 import sys
05728a85e19b add prime.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 for arg in sys.argv[1:]:
05728a85e19b add prime.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 print prime(int(arg))