"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

public class StudentListings{
private String name; // key field
private int ID;
private double GPA;
private int next;
private int size;
private StudentListing[] data;
public StudentListings(){
this.name= name;
this.id= ID;
this.gpa=GPA;
}
public StudentListings(){
next=0;
data= new StudentListings[Size];
size= Size;
} // end of constructor
...