Linear Diophantine Equations | C ++ program to check for solutions of diophantine equations ; utility function to find the GCD of two numbers ; This function checks if integral solutions are possible ; driver function ; First example ; Second example ; Third example
#include <bits/stdc++.h> NEW_LINE using namespace std ; int gcd ( int a , int b ) { return ( a % b == 0 ) ? abs ( b ) : gcd ( b , a % b ) ; } bool isPossible ( int a , int b , int c ) { return ( c % gcd ( a , b ) == 0 ) ; } int main ( ) { int a = 3 , b = 6 , c = 9 ; isPossible ( a , b , c ) ? cout << " Possible STRNEWLINE " : cout << " Not ▁ Possible STRNEWLINE " ; a = 3 , b = 6 , c = 8 ; isPossible ( a , b , c ) ? cout << " Possible STRNEWLINE " : cout << " Not ▁ Possible STRNEWLINE " ; a = 2 , b = 5 , c = 1 ; isPossible ( a , b , c ) ? cout << " Possible STRNEWLINE " : cout << " Not ▁ Possible STRNEWLINE " ; return 0 ; }