Posted by: Sourav | September 10, 2014

GCF using recursion in C


#include<stdio.h>
int gcf(int,int);
 void main()
{
 int i;
 i=gcf(3,27);
 printf(“%d”,i);

}
int gcf(int a,int b)
{
 static int c=2;
 if(((a%c)==0)&&((b%c)==0))
 {
  return c;
 }
 else if((c>a) || (c>b))
 {
  return 1;
 }
 else
 {
  c++;
  gcf(a,b);
 }
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: