Who's Online

We have 28 guests and 2 members online

Login Form



RSS FEEDS



Programme to find HCF using Euclidean algorithm PDF Print
User Rating: / 0
PoorBest 
Program Codes - C Programmig
Written by Mansoorkhan   
Friday, 06 November 2009 03:15
A way of finding the highest common factor of two different numbers:
1) Divide the larger number by the smaller.
2) If the division can be done exactly then the HCF is the smaller number. If there is a remainder then the HCF is the same as the HCF of the remainder and the smaller number - so repeat step 1 with these two numbers.
For instance, to find HCF(17, 20):
20/17 = 1, with remainder 3
so the HCF is the same as HCF(17, 3):
17/3 = 6 with remainder 1
so the HCF is the same as HCF(3, 1):
3/1 = 3; this is exact, so the HCF is 1.

Programme

#include
#include
void hcf(int a,int b);
main()
{
int a,b,t;
clrscr();
printf("Enter two nos : ");
scanf("%d%d",&a,&b);
if(b>a)
{
t=a;
a=b;
b=t;
}
hcf(a,b);
}
void hcf(int a,int b)
{
int x;
x=a%b;
if(x==0)
{
printf("\n\t hcf = %d",b);
getch();
}
else
hcf(b,x);
}
AddThis Social Bookmark Button
 

Copyright Disclaimer: This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.Thanks to Getkerala

For Latest Technology News and computer tips and tricks