4 Replies - 455 Views - Last Post: 23 June 2010 - 06:49 AM Rate Topic: -----

#1 born2c0de   User is offline

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

Reputation: 187
  • View blog
  • 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   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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 =]
Was This Post Helpful? 0
  • +
  • -

#3 Dike   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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
Was This Post Helpful? 0
  • +
  • -

#4 codeguru26   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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.......
Was This Post Helpful? 0
  • +
  • -

#5 akshay shelke   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1