C Programming Code Examples C > Recursion Code Examples C Program to find HCF of a given Number using Recursion C Program to find HCF of a given Number using Recursion The following C program using recursion finds the HCF of two entered integers. The HCF stands for Highest Common Factor. #include <stdio.h> int hcf(int, int); int main() { int x, y, result; printf("Enter the two numbers to find their HCF: "); scanf("%d%d", &x, &y); result = hcf(x, y); printf("The HCF of %d and %d is %d.\n", x, y, result); } int hcf(int x, int y) { while (x != y) { if (x > y) { return hcf(x - y, y); } else { return hcf(x, y - x); } } return x; }