Given two numbers **A** and **B**, the task is to check that A and B are in golden ratio.

**Golden Ratio:** Two numbers are said to be in golden ratio if their ratio is same as the ratio of the sum of the two numbers to the larger number. Here a > b > 0, Below is the geometric representation of the Golden ratio:

**Examples:**

Input:A = 1, B = 0.618Output:YesExplanation:These two numbers together forms Golden ratioInput:A = 61.77, B = 38.22OutputYesExplanation:These two numbers together forms Golden ratio

**Approach:** The idea is to find two ratios and check that these ratio is equal to the Golden ratio. That is 1.618.

// Here A denotes the larger number

Below is the implementation of the above approach:

## Python

`# Python implementation to check ` `# whether two numbers are in ` `# golden ratio with each other ` ` ` `# Function to check that two ` `# numbers are in golden ratio ` `def` `checkGoldenRatio(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` `((a` `+` `b)` `/` `a, ` `3` `) ` ` ` `# Condition to check that two ` ` ` `# numbers are in golden ratio ` ` ` `if` `ratio1 ` `=` `=` `ratio2 ` `and` `\ ` ` ` `ratio1 ` `=` `=` `1.618` `: ` ` ` `print` `(` `"Yes"` `) ` ` ` `return` `True` ` ` `else` `: ` ` ` `print` `(` `"No"` `) ` ` ` `return` `False` ` ` `# Driver Code ` `if` `__name__ ` `=` `=` `"__main__"` `: ` ` ` `a ` `=` `0.618` ` ` `b ` `=` `1` ` ` ` ` `# Function Call ` ` ` `checkGoldenRatio(a, b) ` |

*chevron_right*

*filter_none*

**Output:**

Yes

**References:** https://en.wikipedia.org/wiki/Golden_ratio

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Deriving the expression of Fibonacci Numbers in terms of golden ratio
- Find nth Fibonacci number using Golden ratio
- Sum of two numbers if the original ratio and new ratio obtained by adding a given number to each number is given
- Check whether two numbers are in silver ratio
- Ratio of mth and nth terms of an A. P. with given ratio of sums
- Find the number which when added to the given ratio a : b, the ratio changes to c : d
- Divide an isosceles triangle in two parts with ratio of areas as n:m
- Ratio of the distance between the centers of the circles and the point of intersection of two direct common tangents to the circles
- Ratio of the distance between the centers of the circles and the point of intersection of two transverse common tangents to the circles
- Find the ratio of number of elements in two Arrays from their individual and combined average
- Program to find the common ratio of three numbers
- Check whether a number can be represented by sum of two squares
- Check whether it is possible to join two points given on circle such that distance between them is k
- Check whether two straight lines are orthogonal or not
- Check whether two points (x1, y1) and (x2, y2) lie on same side of a given line or not
- Check whether two convex regular polygon have same center or not
- Check whether a number can be represented as difference of two squares
- Check whether a number can be represented by the product of two squares
- Check whether a number can be represented as difference of two consecutive cubes
- Check whether a number can be expressed as a product of single digit numbers

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.