Do you have a problem with the math involved or the C++ involved? The easiest way to do the math you need using C++ is to use the modulo operator. Assuming m and n are both postive integers, if the result of m % n is zero then, n is a positive proper divisor of m according to the description you provided.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
[TEX]n=mt[/TEX] is the other way of writing that
[TEX]\frac{n}{m}=t [/TEX] where [TEX]t[/TEX] is a integer
it means that if you divide n by m, the division should leave no remainder.
>>we have to use if in these statement (m!=0)(m%n==0)(m>and we don't need to use loop, right??
No
You will have to use the loops for the first part of the question
siddhant3s
Practically a Posting Shark
816 posts since Oct 2007
Reputation Points: 1,486
Solved Threads: 140
input n
vector<int> factors
for(int i = 2; i <= n/2; ++n)
//check if i is factor of n
//if it is add it to the vector
//declare variable to act as running total and initalize to zero
//loop through vector adding elements together
for(int i = 0; i < size of vector; ++i)
//add each element to previous total
//if n equals total from above loop, then n is a perfect number.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396