i cant understand what is wrong with this code.please review it !!
Error while compiling code
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
i am not able to see your response ?
@himanshuep32
you need to further optimize your code you can use sieve of eratosthenes which simply stores prime number upto certain range then you can easily check prime in o(1) time complexity.
how can i remove this error : Exception in thread “main” java.util.NoSuchElementException at java.util.Scanner.throwFor(Scanner.java:862) at java.util.Scanner.next(Scanner.java:1485) at java.util.Scanner.nextInt(Scanner.java:2117) at java.util.Scanner.nextInt(Scanner.java:2076) at Main.main(Main.java:6)
@himanshuep32 NoSuchElementException indicates that the element being requested does not exist. so try to check your loops if they are running for more iterations than needed