"TLE" means time limit error,and that integers could be at most 2^54.So with those big numbers cannot be checked out in one second!!!(Even if you've used sqrt(n)!!!)

"TLE" means time limit error,and that integers could be at most 2^54.So with those big numbers cannot be checked out in one second!!!(Even if you've used sqrt(n)!!!)

I don't think testing a single number of that size presents a time problem. Consider that the square root of 2^54 is 2^27, or about 134 million. On a reasonably modern PC, that is a fairly insignificant task.

Or, are you saying that you have a time limit to meet, and that nothing beyond 2^54 can be done in that time?

The simple, brute force approach we using in teaching examples will, of course, not be the most efficient. There are other algorithms, more complex and mathematically based that you might find and implement.

Yes, I need very effective algoithm. As you said square root of 2^54 is 2^27(about 134million)
and that will be at least one second,but there would be a lot of numbers to be checked.
So what kind of agorithm shall I use?(or where I can find)

Yes, I need very effective algoithm. As you said square root of 2^54 is 2^27(about 134million)
and that will be at least one second,but there would be a lot of numbers to be checked.
So what kind of agorithm shall I use?(or where I can find)

Googling for "fast prime number algorithm" will find some references that may be helpful. Here's one

Write a program that displays all numbers divisible by 3 and 4 within a range entered by user. Display five numbers per line. Numbers are separated by exactly two spaces. ...

Hi guys. I am trying to create a program where the user inputs an integer and the program will cout the nth prime number. Unfortunatly when I try to cout ...

Hello Friends,
I Developed application in C# with crystal reports and created setup file in third party (Advance) Installer.When i installed my application on client system application is working but ...