#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int divides(int,int);
int main ()
{
int count = 10;
//int prime = divides(count);
int p = 0; // number of primes
cout.setf(ios::fixed,ios::floatfield);
cout << setw(6) << "NUMBER" << "\t" << setw(8) << "DIVISORS" << endl << endl;
while (count<=50)
{
//int prime = divides(count); // will return 1 or 0
int sor = 0;
int d = 0; // number of divisors
cout.setf(ios::left);
cout << setw(2) << " " << setw(2) << count << "\t" ;
for (int i=1; i<=count; i++) // i = possible divisor
{
int remainder = 0;
remainder = count%i;
if (remainder==0) {
cout << i << "\t";
d++;
}
}
for (sor<=count){
divides (count, sor)
cout << endl;
//prime = prime+prime; // count divisors
if (d==2) // if there are only two divisors -- number is prime:
p++; // count prime numbers in count
count++;
}
cout << "\n The number of the numbers with only 2 divisors is " << p << "." << endl;
return 0;
}
int divides (int n, int div) {
if (n%div==0)
return 1;
return 0;
}
I hope you see what I'm trying to do. I got the program to work exactly like it had to but I can't figure out how to implement the divides function within the main function, which I need to do. I'm not supposed to do that part of the counting primes within the main function... or whatever it does I don't know how to get it to work inside, like how do I call it and get it to ultimately count up all the primes?! You see like draft attempts I was working on and now I'm trying to add in this function call and you'll see where... but leaving the program as it is how it works, but I need to make the function call work so I can take that out. Please help me and tell me what to do or give me someplace to start or explain it to me. Thank you so much.