WAP to calculate the HCF of two number using recursive function

Write a program to calculate the HCF of two number using recursive function

#include<stdio.h>
#include<math.h>

int hcf(int x, int y) {
	if(y==0)
		return x;
	else 
		return hcf(y, x%y);
}

int main() {
	printf("HCF: %d",hcf(100,70));
	return 0;
}

Output

HCF: 10

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments