hi, i've been working on this problem for way too long and i can't find the answer. here's my code:
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int N; int M; int i;
cout << "Input a positive integer: ";
cin >> N;
cout << endl;
cout << "Testing 1 ->" << endl;
cout << " The divisors: 1" << endl << " The number 1 is not a prime number." << endl << endl ;
if (N <= 0)
cout << "Error: Please, enter a POSITIVE integer.\n";
else
{
for (M = 2; M <= N; M++)
{
cout << "Testing " << M << " ->" << endl;
cout << " The divisors: ";
for (i = 1; i <= N; i++)
{
if (M % i == 0)
{
cout << i << " ";
if (i >= 2)
cout << endl << " The number " << M << " is a prime number." << endl;
}
}
cout << endl;
}
}
system("PAUSE");
return EXIT_SUCCESS;
}
the output is something like
Input a positive integer: 4
Testing 1 ->
The divisors: 1
The number 1 is not a prime number.
Testing 2 ->
The divisors: 1 2
The number 2 is a prime number.
Testing 3 ->
The divisors: 1 3
The number 3 is a prime number.
Testing 4 ->
The divisors: 1 2
The number 4 is a prime number.
4
The number 4 is a prime number.
Press any key to continue . . .
my problem here is that I don't know how to make the numbers that are not prime numbers cout something like "the number 4 is not a prime number" and have the divisors list like "The divisors: 1 2 4" instead of how it's shown.
any help is greatly appreciated