Check whether two numbers are in golden ratio | C # implementation to check whether two numbers are in golden ratio with each other ; Function to check that two numbers are in golden ratio ; Swapping the numbers such that A contains the maximum number between these numbers ; First Ratio ; Second Ratio ; Condition to check that two numbers are in golden ratio ; Driver code ; Function Call
using System ; using System . Collections . Generic ; class GFG { static bool checkGoldenRatio ( float a , float b ) { if ( a <= b ) { float temp = a ; a = b ; b = temp ; } string ratio1 = String . Format ( " { 0:0.000 } " , a / b ) ; string ratio2 = String . Format ( " { 0:0.000 } " , ( a + b ) / a ) ; if ( ratio1 == ratio2 && ratio1 == "1.618" ) { Console . WriteLine ( " Yes " ) ; return true ; } else { Console . WriteLine ( " No " ) ; return false ; } } static void Main ( ) { float a = ( float ) 0.618 ; float b = 1 ; checkGoldenRatio ( a , b ) ; } }