hello, i have another problem i feel that i have to be missing
something.. Basically, i've written a recursive function to find all
the prime up to a number (lim).. here is the function:

The function basically takes in a list of all the prime number found,
it takes the next number to be tested for (next) and the limit it will
go up to. It divide next by the list of previous prime numbers if next
is not bigger than lim, count up all the times where it's not evenly
divdided, if the result is equal the length of prime number, then we
have another prime number, lather rinse and repeat :)

def findPrime(seed, next, lim):
    print("seed: " + str(seed) + " next: " + str(next) + " lim: " +
str(lim))
    print(seed)
    if(next >= lim):
        print(seed)
        return seed
    else:
        count = 0;
        for num in seed:
            modu = math.modf(float(next)/float(num));
            if(modu[0] > 0):
                count += 1
        if(count == len(seed)):
            seed.append(next)
            findPrime(seed, next+2, lim)
        else:
            findPrime(seed, next+2, lim)

As you can probably see, i've printed the value of seed up until the
point where i'm returning the seed, however, the function still returns
None..

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to