/********************************************************************** HCF (Highest common factor) program with two numbers in c **********************************************************************/ #include<stdio.h> int main(){ int number_1,number_2; printf("\nEnter two numbers:"); scanf("%d %d",&number_1,&number_2); while(number_1!=number_2){ if(number_1>=number_2-1) number_1=number_1-number_2; else number_2=number_2-number_1; } printf("\nGCD=%d",number_1); return 0; } /* OUTPUT: Enter two numbers:3 12 GCD=3 */
Leave a Reply