Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Prime Number implementation

Name: Anonymous 2011-03-20 8:29


def factors(x):
    '''returns the factors for an integer'''
    facts=[]
    for i in range(x+1):
        if i==0:
            continue
        elif x%i==0:
            facts.append(i)
    return facts

def isprime(x):
    y=factors(x)
    if len(y)==2:
        return True
    else:
        return False

Name: Anonymous 2011-03-20 15:47

>>13
Even better: Store all primes ever found this way into a file and load them up before running it!

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List