# finding out what two numbers go into a number with no remainder.

• 02-25-2002
Dummies102
finding out what two numbers go into a number with no remainder.
I'm trying to make a program that will try to find two perfect square numbers(4, 9, 16, etc)(x, and y) that go into another number(z) with no remainder, then try to square root x and y as far as they go, while still being a whole number. for example, if I enter 32, if will see that 16 and 2 go into 32 evenly, and that 16 can be square rooted to 4, and 4 to 2. but won't except, for example, 8 and for, because 8 can't be square rooted evenly. I have an idea where to go with this, like check to see if all the perfect squares multiplyed together equaled the number, but there's got to be an easyer algorythem then 1000+ if statements. if anyone has any ideas or links on where to go with this, I'd appreciate it alot, thanks.
• 02-25-2002
ihsir
some code help

cin>>num;

i=1;
rem=1;
while(rem!=0)
{
i=i+1;
quo=num/i;
rem=num%i;
}
cout<<"number : "<<num<<" = "<<quo<<"*"<<i;
• 02-25-2002
ihsir
also i would like to know what do you want to do if the user enters 33...
• 02-25-2002
Dummies102
33's not a perfect square, so the program would say something like, "that's not a perfect square". and thanks for the code, it'll give me some great ideas.

here's some of the code I have now, but I think the syntax is all wrong.

Pyth.h:
#include <math.h>
/*
double PythRoot(double one, double two);
double PythSquare(double one, double two);
double PythSide(double one, double two);
double PythSideSquare(double one, double two);
I origonally had these included, but I took them out and they made no difference, so here they are.
*/

double PythRoot(double one, double two)//finds the length of the hypotenuse plain and simple
{
one = pow(one, 2);
two = pow(two, 2);
one = one + two;
two = sqrt(one);
return two;
}
double PythSquare(double one, double two)//finds the length of the hypotenuse befre it is square rooted into a simpler form. Used for Simplifying roots.
{
one = pow(one, 2);
two = pow(two, 2);
one = one + two;
return one;
}
double PythSide(double one, double two)//finds the length of a side of a right triangle when only the hypotenuse and another side are advailable.
{
one = pow(one, 2);
two = pow(two, 2);
one = two - one;
two = sqrt(one);
return two;
}
double PythSideSquare(double one, double two)//does the above, but does not square root it.
{
one = pow(one, 2);
two = pow(two, 2);
one = two - one;
}
double PythSimp(int i, double one, double two)
{
one = one * one;
two = two * two;
one = one + two;
for(i=1; %(one/i)<1; i++) // I don't think the middle statement is correct
{
two=one/i;
}
return two;
}

Pyth.cpp:

#include <iostream.h>
#include "Pyth.h"//path changed
int main()
{
double one, two, hyp, side, i;
cout << "enter in the length of a side, then the hypotenuse";
cin>>one>>two;
cout << "the hypotenuse square should be"<<PythSquare(one, two)<<"now, the next number is our lucky number, it should be the number on the left, simplifyed, let's pray."<<PythSimp(i, one, two)<<endl;
}

also, on my if statement of the last function of Pyth.h when it says
for(i=1; %(one/i)<1; i=i+1)
how do I make is stop when i reaches 144?

thanks again for help