Name: Anonymous 2007-06-18 11:04 ID:qFudCK33
so i was playing with factor and i wrote this function:
it takes less than a second to determine that 2003663613*2^195000+1 (the largest known prime number according to http://primes.utm.edu/largest.html) is prime and less than a second to determine that 2003663613*2^195000 is not...
so i'm wondering... how would one go about doing this in other languages?
: prime? ( n -- ? ) [ dup sqrt >bignum 1 - [ 2 + , ] each ] { } make [ 2dup mod swap drop ] map [ 0 = ] find drop not swap 1 > and ;it takes less than a second to determine that 2003663613*2^195000+1 (the largest known prime number according to http://primes.utm.edu/largest.html) is prime and less than a second to determine that 2003663613*2^195000 is not...
so i'm wondering... how would one go about doing this in other languages?