/* File: gcd.cpp Christer Karlsson This code implements a function that calculates the GCD(M,N). Allowed inputs are integers. The program breaks if nothing is entered */ #include using namespace std; // Constants and global variables // Functions // Start of the recursive function int GCD (long int M, long int N) { // n is sent in by value if (N==0) return M; // returns 1 if n=0 else return GCD(N,M%N); } // End of recursive function /* The recursive Function prototype one values will be passed by value */ int main() { int M=0; int N=0; char comma; int answer; do { cout << "Enter an M,N: "; cin >> M >> comma >> N; answer=GCD(M,N); // Call for the recursice function cout << answer << '\n'; } while(true); return 0; }