Total members 10249 | Gratitudes |It is currently Thu May 17, 2012 8:07 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Question
 Question subject: Greatest common divisor
PostPosted: Sun May 25, 2008 3:48 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2272
Location: Earth
Has thanked: 39 time
Have thanks: 61 time

Greatest common divisor in c++ using recursion method :gOOd:

Code:
#include<iostream>
using namespace std; 
int GCD(int ,int );   
void main()
{
   int x,y;
   cout<<"Plz enter the two numbers : ";
   cin>>x>>y;
   cout<<"The GCD("<<x<<","<<y<<") = " << GCD(x,y)<<endl;
}
int GCD(int x,int y)
{
   if(y>x)return GCD(y,x);
   if(x==y)return x;
   if(x%y==0)return y;
   return GCD(x,x-y);

}

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 NEED CODE OF find any num all divisor using recursion?
 Six Common Enterprise Programming Mistakes
 Greatest Comman Divisor using Java

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 2 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team