Help!! Getting perfect numbers from two values.

Find the perfect numbers between a starting value and a finishing value entered by the users. Display the results to the screen. YOU MUST DESIGN YOUR SOLUTION WITH FUNCTIONS.

I've been told that I need to modify things under the void and the calcdiv in my main () but I can't seem to figure it out. It needs display the perfect numbers between the starting and finishing value. e.g. 28 and 429.


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

void calcdiv(int number)
{
for (int i=1;i<=number/2;i++)
{
if (number % i == 0)
{
cout << i << endl;
}
}
}

int main()
{
int i;
int number;

cout << "Enter Starting Value.";
cin >> i;

cout << "Enter Finishing Value." << endl;
cin >> number;


calcdiv(i%number);

return 0;
}
Thank you!
bump
see this:

http://en.wikipedia.org/wiki/Perfect_number

on how a perfect number has to be calculated.

It's rather simple: this if (number % i == 0) tells you i is a divisor. Now you have to add them all including the number itself. Divided by 2 must be equal number

This calcdiv(i%number); is wrong. You need to provide the start and end value:

calcdiv(i , number);
Thank you!
Topic archived. No new replies allowed.