I was wondering what the issue was with my prime number code. I feel it might have to do with the arrangement of my repetition but I am not sure. The idea was as a prime number can only be divisible evenly by 1 and itself that I would use f_check to check this. It only out puts numbers 2 and 3. Where did I go wrong?
int [] f_numb;
double f_pri;
int f_check = 0;
f_numb = new int [101];
for (int cnto = 2; cnto<=100; cnto++) {
f_numb [cnto] = cnto;
for( int cnt=100; cnt>=1; cnt--) {
f_pri = f_numb [cnto]%cnt;
if (f_pri==0) {
f_check=f_check+1;
}
}
if (f_check == 2) {
System.out.println(f_numb [cnto]);
f_check = 0;
}
}