Given two numbers A and B, the task is to check that A and B are in silver ratio.
Silver Ratio: Two numbers are said to be in silver ratio if the ratio of the sum of the smaller and twice the larger number to the larger number is the same as the ratio of the larger one to the smaller one. Below is the representation of the silver ratio:
for A > 0, B > 0
Input: A = 2.414, B = 1
Input: A = 1, B = 0.414
Explanation: Ratio of A to B do not form a golden ratio
Approach: The idea is to find two ratios and check whether they are equal to the silver ratio(2.414).
// Here A denotes the larger number
Below is the implementation of the above approach:
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Check whether two numbers are in golden ratio
- Sum of two numbers if the original ratio and new ratio obtained by adding a given number to each number is given
- Find ratio of zeroes, positive numbers and negative numbers in the Array
- Program to find the common ratio of three numbers
- Deriving the expression of Fibonacci Numbers in terms of golden ratio
- Find the number which when added to the given ratio a : b, the ratio changes to c : d
- Ratio of mth and nth terms of an A. P. with given ratio of sums
- Check if a given pair of Numbers are Betrothed numbers or not
- Check if two numbers are co-prime or not
- Check whether XOR of all numbers in a given range is even or odd
- Check whether product of 'n' numbers is even or odd
- Check if sum of divisors of two numbers are same
- Check whether the given numbers are Cousin prime or not
- Check if the given two numbers are friendly pair or not
- Check if two numbers have same number of digits
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.