to find the prime number, i used the sieve of erastosthenes algorithm to reduce the time complexity, but it is still taking a lot of time. do you have a better algorithm for it?
Prime visits question
you have to optimize your code
use this things
- check for only odd nos
- start form ii and increment i every time instead of 1;
for(int i=3;i<=n;i+=2){
for(int j=ii;j<=n;j+=i){
}
}
use these optimization trick