/*find gratest common devider of given two nombers*/
#include<stdio.h>
//Function to find GCD from Euclid's algorithm:
long int gcd(long int a, long int b)
{
if (b > a)
{
return gcd(b, a);
}
if (b == 0)
{
return a;
}
else
{
return gcd(b, a % b);
}
}
void main()
{
long int a, b;
long int gcd(long int, long int);
// clrscr();
printf("Program to finf greatest comman devider: ");
printf("\nEnter first number: ");
scanf("%ld", &a);
printf("\nEnter second number: ");
scanf("%ld", &b);
printf("\nGreatest comman devider is: %ld", gcd(a, b));
// getch();
}
No comments:
Post a Comment