Random Prime Generator/Modular Arithmetic

Astan Chee stanc at al.com.au
Sun Mar 5 10:07:20 EST 2006


Also you last code which looked like:

def cran_rand(min,max):
    if(min>max):
        x=max
        max=min
        min=x
    range=round(log(max-min)/log(256))
    if range==0:
        range=1
    num=max+1
    while(num>max):
        num=min+s2num(urandom(range))
    return num


what does s2num do? im assuming it changes string chars to ascii 
decimal? Is that correct?
and  i thought is_prime would work better if you listed all small primes 
(<20000) and check if they are divisible by those.
Aside from that Im really interested in your cran_rand function as I 
havent fully tested it out yet.
Cheers


Tuvas wrote:

>Hmmmm. Well, I don't know what else I could do, except for to write a
>function that doesn't require recursion. Still, 300 digits isn't too
>bad... I have also realized that if you try is_prime(3) it will return
>false. I'll have to work on it... Thanks for the help!
>
>  
>



More information about the Python-list mailing list