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:
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.
- 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 golden 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
- Find ratio of zeroes, positive numbers and negative numbers in the Array
- Check whether the number formed by concatenating two numbers is a perfect square or not
- 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
- Deriving the expression of Fibonacci Numbers in terms of golden ratio
- 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
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.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.