# Finding GCD of two numbers using Euclid's Algorithm

Page 1 of 1

## 4 Replies - 555 Views - Last Post: 23 June 2010 - 06:49 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=364150&amp;s=c688f4ba8d9ac0ca7cd7cbf87d790079&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 born2c0de

• printf("I'm a %XR",195936478);

Reputation: 187
• Posts: 4,673
• Joined: 26-November 04

# Finding GCD of two numbers using Euclid's Algorithm

Posted 29 October 2005 - 07:50 PM

Description: Finds the GCD/HCF of a number using Euclid's Recursive Algorithm.
```/*
Written by Sanchit Karve A.K.A born2c0de
born2c0de AT hotmail DOT com
*/
#include <stdio>

int euclid(int a,int b)
{
if(b==0)
return a;
else
return euclid(b,a%b);
}

int main()
{
int n1,n2;
printf("Enter two numbers to find its GCD:");
scanf("%d %d",&n1,&n2);
printf("The GCD of %d and %d is %d",n1,n2,euclid(n1,n2));
return 0;
}

```

Is This A Good Question/Topic? 0

## Replies To: Finding GCD of two numbers using Euclid's Algorithm

### #2 ISAI

Reputation: 0
• Posts: 41
• Joined: 26-December 07

## Re: Finding GCD of two numbers using Euclid's Algorithm

Posted 16 January 2008 - 12:21 PM

Good job. very helpful, thanks a lot =]

### #3 Dike

Reputation: 0
• Posts: 2
• Joined: 28-April 09

## Re: Finding GCD of two numbers using Euclid's Algorithm

Posted 28 April 2009 - 09:47 PM

I was looking for this. Thank you so much

### #4 codeguru26

Reputation: 0
• Posts: 10
• Joined: 31-March 10

## Re: Finding GCD of two numbers using Euclid's Algorithm

Posted 29 May 2010 - 07:19 AM

Very nice.......

### #5 akshay shelke

Reputation: 0
• Posts: 0
• Joined: 23-June 10

## Re: Finding GCD of two numbers using Euclid's Algorithm

Posted 23 June 2010 - 06:49 AM

ok sir(sai campusys) find iti