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:
Input: A = 1, B = 0.618 Output: Yes Explanation: These two numbers together forms Golden ratio Input: A = 61.77, B = 38.22 Output Yes Explanation: 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:
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.
- 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 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.