hi everyone

i have a minor problem. my for loop wont count right. i am so confused as to why it will not work. so if anyone can be of some assistance i would greatly appreciate it.

i am over looking something and over analyzing this so i need an outside opinion.

purpose of program is to test numbers to see if they are prime. just in case you are wondering.

Inside my function "find_prime" i have for loop and it is always equal to 2. The idea is to count up and divide the number by various numbers (j) to see if it is prime.

My if statement is never true for some reason so can someone please give me some ideas how to make this work right. thanks

Code:#include <iostream> #include <iomanip> using namespace std; bool find_prime(int); int main () { int i, counter =0; bool test; for (i =2; i <= 500; i++) { test = find_prime(i); if ( test == true ) { counter++; cout << setw(6) << i << "\t"; } } cout << "\nThe total number of the prime numbers between 2 and " << i << " is " << counter << endl; return 0; } bool find_prime (int m) { int temp, j; for ( j = 2; j < m - 1 ; j++ ) { temp = m % j; if (temp == 0) { cout << "j is " << j; return false; } else { return true; break; } }}