Given two Rational numbers, the task is to find the maximum of given two rational numbers.
Input : first = 3/4, second= 3/2 Output : 3/2 Input : first = 100/100, second = 300/400 Output : 100/100
A simple solution is to find float values and compare the float values. The float computations may cause precision errors. We can avoid them using below approach.
Say first = 3/2, second = 3/4
- First take a LCM of (4, 2) which is denominator of rational number. so the LCM of this is 4, then divide with both denominator and multiple with numerator of first and second respectively so the denominator value is first numerator = 6, second numerator = 3.
- Then find the max between these two. so here first numerator is max then print first rational number.
- Find LCM of rational numbers
- HCF of array of fractions (or rational numbers)
- N-th term of George Cantor set of rational numbers
- Algorithm to generate positive rational numbers
- Binary Search for Rational Numbers without using floating point arithmetic
- as_integer_ratio() in Python for reduced fraction of a given rational
- Maximum rational number (or fraction) from an array
- Find two numbers whose sum and GCD are given
- Given two numbers a and b find all x such that a % x = b
- Find XOR of numbers from the range [L, R]
- Find two numbers with sum and product both same as N
- Find the sum of first N odd Fibonacci numbers
- Find k numbers which are powers of 2 and have sum N | Set 1
- Program to find LCM of two numbers
- Find two prime numbers with given sum
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.