Jump to content
  • Advertisement
Sign in to follow this  
Death2You

Numerator / Denominator

This topic is 4614 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I need to do a program where i must enter a numerator and denominator and nummerator and the computer to tell me what the draction is. so 4 /12=1/3 I honestly have no idea how to do that. lol int main() { int Num; int Den; cout<<"Enter a Numerator:"<<endl; cin>>Num; cout<<"Enter a Denominator:"<<endl; cin>>Den; Reduce(Num,Den); return(0); } //-------------------------- void Reduce(int Num, int Den){ //Now what the hell do i put in here. I honestly have no clue what formulas i need to use. Anywho can someone help me, and well if you wont let me get off that easy, you can give me hints i guess. thanks

Share this post


Link to post
Share on other sites
Advertisement
Step one is to walk away from your computer, find a piece of paper, and figure out how exactly you'd accomplish what you want. For example, you said 4/14 == 1/3. How did you arrive at that, what steps did you take?

Once you've come up with the proper algorithm, you might find your task a little easier.

Share this post


Link to post
Share on other sites
Washu is correct.

I'll give you a bit more help.

Every number is made up of a series of prime numbers. eg
4 == 2*2
8 == 2*2*2
12 == 2*2*3
21 == 21
100 == 2*2*5*5

Now you just need to remove the primes that are the same to get the reduced form. So 4/8 == (2*2)/(2*2*2) == 1/2

Hope this helps.

Greig

Edit: Although I really shouldn't be doing other peoples homework.

Share this post


Link to post
Share on other sites
No No No your not giving me hw. sry but thanks that really helped. The example you gave me helped me a lot. Im sry im just not that good with setting formulas up. lol thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!