Check whether two numbers are in silver ratio | Function to check that two numbers are in silver 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 silver ratio ; Driver Code ; Function call
function checksilverRatio ( a , b ) { if ( a < b ) { a = a + b ; b = a - b ; a = a - b ; } let ratio1 = ( ( a / b ) * 1000 ) / 1000 ; let ratio2 = Math . floor ( ( ( 2 * a + b ) / a ) * 1000 ) ; ratio2 = ratio2 / 1000 ; if ( ratio1 == ratio2 && ( ratio1 - 2.414 ) == 0 ) { document . write ( " " ) ; return true ; } else { document . write ( " " ) ; return false ; } } let a = 2.414 ; let b = 1 ; checksilverRatio ( a , b ) ;