I want to write a program by computer to simplyfie numeratour and denamerator which is key in by user for example 40/8 how can I delighten computer that simplyfy 12/3 or any other number
40/5,60/3 etc I need a formula for doing this THX
2007-07-19
03:10:18
·
8 answers
·
asked by
Anonymous
in
Science & Mathematics
➔ Mathematics
I know that i can divide by 4 but the numbers which is keying in by user are random may be 66/3 so then i need formula for that
2007-07-19
03:13:29 ·
update #1
Read about the Euclidean algorithm. It does this exactly, its a little too long to discuss here, but I am sure you can find it on the internet somewhere. "The Euclidean Algorithm" finds the gcd of two numbers. Once you have found the gcd, simply divide each numerator and denominator by the gcd, and it is simplified.
2007-07-19 03:22:24
·
answer #1
·
answered by Jeƒƒ Lebowski 6
·
1⤊
0⤋
Your program will neeed to include an algorithm for finding the prime factors of each number. There is no simple formula for doing that. You just have to work through all the primes in turn looking for factors.
The program should then remove those factors common to both numerator and denominator, and multiply together the remaining factors for each of the numerator and denominator to determine the two numbers needed in the result.
For 120/21 you would then proceed as follows:
120 would yield 2^3 * 3 * 5
21 would yield 3 * 7
3 would be eliminated
The result would be 40/7.
2007-07-19 10:20:28
·
answer #2
·
answered by Anonymous
·
0⤊
0⤋
If you're given the numerator and the denominator, I would say that the easiest way would be to actually divide the number.
40/8 would become 5.
12/3 would become 4.
In the case where you don't have a whole number, or you have an imperfect fraction, e.g. 42/8.
Here's what I would do.
Divide numerator(N) 42 by denominator(D)8. You'll get 5.25
Store 5.25 in a variable (X) and then truncate the 5.25.
You're left with 5.0
Multiply 5.9 (X) by the denominator (D) and subtract that from the numerator (N)
you're left with 2. Store that in a new numerator variable (N1).
Now display X, N1 / N2 and you have 5 2/8.
2007-07-19 10:31:02
·
answer #3
·
answered by Brandon B 2
·
0⤊
0⤋
Numerator 12 / 3 = 4
Denominator 3 / 3 = 1
Simplified: 4/1 or 4
2007-07-23 04:15:33
·
answer #4
·
answered by Jun Agruda 7
·
2⤊
0⤋
divide by 3, actually
simplify 12 / 3
= 4
How about programming your computer to find the factors of the numerator and the factors of the denominator
Then if there are factors in common, the numerator and denominator can be divided by these factors and thus simplified.
eg. 12/3
= 2x2x3 / 3
= 2x2
= 4
2007-07-19 10:17:00
·
answer #5
·
answered by Orinoco 7
·
1⤊
1⤋
Most higher-level programming languages have at a minimum simple arithmetic capabilities. For division, it is usually a "/" symbol, for multiplication it is usually a "*" symbol, etc. Refer to the programming language of your choice for specifics. As a rather generic example in PERL (Note for clarity, I left out a few lines that would clean up the data):
print "Enter numerator: ";
$numerator=;
print "Enter denominator: ";
$denominator=;
$answer =$numerator/$denominator;
print $answer;
2007-07-19 10:20:28
·
answer #6
·
answered by N E 7
·
0⤊
0⤋
If you are using Microsoft excel, just click inbox A type = then click box B type / click box below it (Box C) press enter.
Type numerator amount into box B and denominator amount into box C.
Answer will appear in box A. Good luck!
2007-07-19 10:20:27
·
answer #7
·
answered by wygot 1
·
0⤊
0⤋
the answer is 4/1
2007-07-19 10:18:39
·
answer #8
·
answered by Skatergal 2
·
0⤊
0⤋