highest common factor algorithm in c

#include <stdio.h>

int hcf(int a, int b) {
    if (b != 0) {
        return hcf(b, a % b);
    } else {
        return a;
    }
}

int main() {
    int num1, num2;
    printf("Enter two numbers: ");
    scanf("%d %d", &num1, &num2);
    int result = hcf(num1, num2);
    printf("The highest common factor of %d and %d is %d\n", num1, num2, result);
    return 0;
}