//* Carying in progress values of calculations in a loop *
#include <iostream> using namespace std; int main() { int n1, n2; cout << "Please enter two numbers to find their GCD "; cin >> n1 >> n2; int gcd=1, k=1; while (k<=n1 && k<=n2) { if(n1%k==0 && n2%k==0) gcd=k; // Note: this is a brute force approach // just throw a fast computer at it and wait k++; } cout << "The GCD of " << n1 << " and " << n2 << " is " << gcd << endl; return(0); } /* */