0
how to check big prime numbers in Java
how to check big prime numbers in Java
3 Respostas
+ 7
Inspired by James' answer:
https://code.sololearn.com/cUsgvP1qFvW4/?ref=app
I didn't search for optimized algorithms, so it's just a little messy code and not mind blowing 😊
+ 1
There are quite a lot of good algorithms out there for finding out if a number is a prime. I would start by checking if the number is divisible by two, if it's not then check all of the odd numbers from 3 to the square root of the number. This isn't the best algorithm but it's a start. You can then do some tricks like memoization that can trade memory for runtime.