Public Group

# 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.

## 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 on other sites
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 on other sites
Don't ask if it's homework...

##### Share on other sites
Hint: discrete math is your friend.

##### 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 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

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

• 13
• 78
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632968
• Total Posts
3009587
• ### Who's Online (See full list)

There are no registered users currently online

×