# Check whether two numbers are in silver ratio

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

Examples:

Input: A = 2.414, B = 1
Output: Yes
Explanation: Input: A = 1, B = 0.414
Output No
Explanation: Ratio of A to B do not form a golden ratio

## Recommended: Please try your approach on {IDE} first, before moving on to the solution.

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:

## Python

 # Python implementation to check   # whether two numbers are in   # silver ratio with each other     # Function to check that two   # numbers are in silver ratio  def checksilverRatio(a, b):             # Swapping the numbers such       # that A contains the maximum      # number between these numbers      a, b = max(a, b), min(a, b)             # First Ratio      ratio1 = round(a / b, 3)             # Second Ratio      ratio2 = round((2 * a + b)/a, 3)      # Condition to check that two      # numbers are in silver ratio      if ratio1 == ratio2 and\         ratio1 == 2.414:          print("Yes")          return True     else:          print("No")          return False            # Driver Code  if __name__ == "__main__":      a = 2.414     b = 1            # Function Call      checksilverRatio(a, b)

Output:

Yes


References: https://en.wikipedia.org/wiki/Silver_ratio

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

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. 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.