I have to find factors of 1-10 then count all factors and find if they are odd/even. I know how to find if they are even or odd i just can't count how many factors for each number.

#include <iostream.h>
#include <stdlib.h>

int main()
{
int num, icntA, icntB, icntC, sub = 0.0;
int total = 0.0;
cout << "Please enter a positive maxiumum integer value you wish to find divisors: \n";
cin >> num;

for(icntA = 1; icntA <= num; icntA++)
{
for(icntB = 1; icntB <= num; icntB++)
{
if(icntA % icntB == 0)
cout << icntB << " " ;

}

sub = ( icntB/icntB);
total = total + sub;
cout << endl;
}

cout << "total of open: "<< total << endl;
system("pause");
return 0;
}

thank you for any help

1
Contributor
1
2
Views
5 Years
Discussion Span
Last Post by anton_f

so
1: 1(odd)
2: 1,2(total of factors = 2)(even)
3: 1,3(even)
4: 1,2,4(odd)
5: 1,5(even)
6: 1,2,3,6(even)
7: 1,7(even)
8: 1,2,4,8(even)
9: 1,3,9(odd)
10: 1,2,5,10(even)
but the "total" only thing I need is total but it keeps displaying every factor for every number.
total of odds = 3

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.