Prime visits question

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?

you have to optimize your code
use this things

  1. check for only odd nos
  2. start form ii and increment i every time instead of 1;
    for(int i=3;i<=n;i+=2){
    for(int j=i
    i;j<=n;j+=i){

}
}
use these optimization trick