Find smallest values of x and y such that ax | C ++ program to find the smallest values of x and y that satisfy " ax ▁ - ▁ by ▁ = ▁ 0" ; To find GCD using Eculcid 's algorithm ; Prints smallest values of x and y that satisfy " ax ▁ - ▁ by ▁ = ▁ 0" ; Find LCM ; Driver program
#include <iostream> NEW_LINE using namespace std ; int gcd ( int a , int b ) { if ( b == 0 ) return a ; return ( gcd ( b , a % b ) ) ; } void findSmallest ( int a , int b ) { int lcm = ( a * b ) / gcd ( a , b ) ; cout << " x ▁ = ▁ " << lcm / a << " y = " } int main ( ) { int a = 25 , b = 35 ; findSmallest ( a , b ) ; return 0 ; }