iterative highest common factor hcf
#include <iostream>
using namespace std;
int hcf(int a, int b) {
while (a != b) {
if (a > b)
a = a - b;
else
b = b - a;
}
return a;
}
int main() {
int a = 24, b = 36;
cout << hcf(a, b) << endl;
return 0;
}