// Highest common factor (HCF) = the largest integer that two or more numbers can be divided by
class MyClass
{
static int HFC(int divided, int divisor) {
int? remainder;
var hcf = 0;
do {
remainder = divided % divisor;
if (remainder == 0) {
hcf = divisor;
}
else {
divided = divisor;
divisor = remainder;
}
} while (remainder != 0);
return hcf;
}
static void main()
{
var divided = 18;
var divisor = 27;
print("HCF = " + (MyClass.HFC(divided, divisor)).toString());
}
}
void main() {
MyClass.main();
}
/*
run:
HCF = 9
*/