Find x and y satisfying ax + by = n | function to find the solution ; traverse for all possible values ; check if it is satisfying the equation ; Driver code
function solution ( a , b , n ) { for ( let i = 0 ; i * a <= n ; i ++ ) { if ( ( n - ( i * a ) ) % b == 0 ) { document . write ( " " + i + " " + ( n - ( i * a ) ) / b ) ; return ; } } document . write ( " " ) ; } let a = 2 , b = 3 , n = 7 ; solution ( a , b , n ) ;