Hey guys. So I am trying to just get a method that can tell me if a BigInteger is FOR SURE prime, and I have had little luck. The best method that I have found online says 25 is prime... anyone know a good way to do it?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hey guys. So I am trying to just get a method that can tell me if a BigInteger is FOR SURE prime, and I have had little luck. The best method that I have found online says 25 is prime... anyone know a good way to do it?
You see, the computation of primes always was pretty difficult problem. You have to do lot's of computations to discover whether a number is a prime or not. The most straightforward algorithm is to check whether a number can be divided by some number less than it. And it appears to be pretty efficient, but not in the context of prime number generator.
For large numbers, you would have to look deeper and study things like the Sieves of Eratosthenes, Euler etc ... (Sieve of Eratosthenes - Wikipedia, the free encyclopedia)