fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n1, n2;
  6.  
  7. cout << "Enter two numbers:";
  8. cin >> n1 >> n2;
  9.  
  10. while(n1 != n2) {
  11. if (n1 > n2)
  12. n1 -= n2;
  13. else
  14. n2 -= n1;
  15. }
  16.  
  17. cout << "HCF =" << n1;
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5464KB
stdin
23
89
stdout
Enter two numbers:HCF =1