Click to See Complete Forum and Search --> : Help Needed With RSA Algorithm


sjaguar13
October 3rd, 2005, 03:13 AM
I am working on a program that uses the RSA algorithm, but I ran into a problem early in development. How do I find a big prime number (12 or more digits) without having to have a list of prime numbers up to the number I want to check? For example, the only way I know how to check for primes it to divide by every prime up to that number so for 13, I would divide by 11, 7, 5, 3, and 2. What if I wanted to check 349045893493? I don't want to have to create a list of primes up to that.

mehdi62b
October 3rd, 2005, 06:25 AM
you can count from 2 to sqrt of that number it should not have any factor otherwise its not a prime number bool IsPrime(int n)
for i=2 to [sqrt(n)]
if (n mod i==0) return false
return true