# 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

OutputNo

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:

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

*chevron_right*

*filter_none*

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

## Recommended Posts:

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