Finding Factors

I'm trying to make a program that will find the factors of a number, this is currently what I have. When I run the program I can enter a number but when i press enter nothing happens, it just sits there. Did I do something wrong in the code?

#include <iostream>
using namespace std;

int main()
{
int number;
int factor;
int testNumber;

cout << "This will find the factors of a number\n\n";
cout << "Please enter a number: ";
cin >> number;

testNumber = number;

while( testNumber > 0 );
{
if( number%testNumber == 0 )
{
factor = number/testNumber;
cout << factor << "is a factor\n";
}

testNumber = testNumber - 1;
}

system( "pause" );
}
What do you mean by "it just sits there"? Does it not print out any text? Or does it just start but nothing happens?
It is the ; after while( testNumber > 0 );. Remove it.
It is the ; after while( testNumber > 0 );. Remove it.


thanks duno why I didn't see that earlier
Topic archived. No new replies allowed.