view python/prime.py @ 501:f9a4e1572b54

add http://pietrushnic.blogspot.com/2012/02/arbtt-as-productivity-improver-for.html#.Uh_LB5WZi1E
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 29 Aug 2013 15:36:08 -0700
parents 8593b0384d3e
children b5a59c3e4421
line wrap: on
line source

#!/usr/bin/env python

def prime(number):
    half = int(number / 2)
    for i in range(2, half):
        if not number % i:
            return False
    return True

def primes(n):
    return [i for i in range(2,n)
            if not [True for j in range(2,1 + i/2)
                    if not i%j]]


if __name__ == '__main__':
    import sys
    for arg in sys.argv[1:]:
        print prime(int(arg))