Comments

Whats Wrong With this logic every time exception was occuring or it is Same as ABove logic but not Working for java

static void Sieve() {
    for (int i = 2; i < MAX; i += 2)
       sp[i] = 2;// even numbers have smallest prime factor 2
    for (int i = 3; i < MAX; i += 2) {
       if (!v[i]) {
         sp[i] = i;
         for (int j = i; (j * i) < MAX; j+=2) {
          if (!v[j * i])
              v[j * i] = true;
          sp[j * i] = i;
         }
       }
    }
}

actually i am converting it in java code may be due to i am getting this...if u can convert this in java then it would be very helpful for me and for othes..plz do it soon

hey smallest prime factor for 567 is 3 but you program is outputing 7...plz correct it