473,804 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

plz tell me how 2 find GCD(greater common diviser)

actually i have recently started learning C++, i have my paper of C++
tommorow......s o plz help me how 2 find GCD .......

Jul 23 '05 #1
3 1565

<mu******@gmail .com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
actually i have recently started learning C++, i have my paper of C++
tommorow......s o plz help me how 2 find GCD .......

To get you started, I recommend that you research Euclid's algorithm:
http://en.wikipedia.org/wiki/Euclid%27s_algorithm

Regards,
Sumit.
--
Sumit Rajan <su*********@gm ail.com>
Jul 23 '05 #2
<mu******@gmail .com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
actually i have recently started learning C++, i have my paper of C++
tommorow......s o plz help me how 2 find GCD .......


Do a google search for "Euclidean Algorithm".

--
David Hilsee
Jul 23 '05 #3
mu******@gmail. com wrote:
actually i have recently started learning C++, i have my paper of C++
tommorow......s o plz help me how 2 find GCD .......


Hit the books. For instance

Knuth: The Art of Computer Programming II -- Seminumerical Algorithms
[Chapters 4.5.2 and 4.5.3, pages 333-378]

discusses various algorithms for finding the GCD in detail. Alternatively,
you can use Google (e.g., Euclid's Algorithm comes to mind).

Once you settled on a method try to implement it in C++ and when you have a
specific C++ question, we might be able to help you.
Best

Kai-Uwe Bux
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1095
by: Brandon Potter | last post by:
Trying to find the best way to find common entries in an x number of ArrayLists or arrays of integers. Curious if there is a method already available in .NET to do just this very thing. Situation is that each array contains search results for a given criteria, but the end result should only give the search results that are common to all arrays of results. i.e., SearchArrayOne = 100
16
2083
by: Justin Hoffman | last post by:
This is a question concerning query optimisation. Sorry if it's a bit long, but thanks to anyone who has the patience to help - This is my first post here... If I have two tables: 'tblContact' and 'tblCategory' where categories are like: Code Name 010101 Short 010102 Fat
3
2230
by: Massimiliano Alberti | last post by:
Can someone check this? If it's OK, you can use however you want... :-) It should search for an element in an array and, if it can't find it, return the next element. key is what you are searching, in a *base array of LONG with num elements. After some tests it seems to work well (the original version was filled with ASSERTs) (I will use this function in a bigger look-for-or-insert function) Some notes: The function returns the index...
1
1462
by: Nishant | last post by:
Hi there, I am looking forward to your help for comparing matrix in C++ I want to find common elements between 2 or more different matrices,using C++ for eg: A=
74
7493
by: lovecreatesbeauty | last post by:
My small function works, but I have some questions. And I want to listen to you on How it is implemented? 1. The function does not check if parameter x is larger or smaller than parameter y. 2. Is it better to use unsigned int or unsigned long as the type of parameters x and y? This change may remove the if statement. More comments are still welcome.
4
13700
by: sdlt85 | last post by:
Hi, Can someone help me with an idea on how to start writing a C++ code for generating greatest common divisor and the linear combination of two intergers represented as gcd(m, n)= mx + ny and adding them it will give us the greatest common divisor and I need to use the extended Euclidean algorithm. I already have the code for the greatest common divisor but I dont know how to do the linear combination. This is what I have:
15
3685
by: judge82 | last post by:
I'm new to Java and I was looking for some help on this particular problem. I need to create a method that can simplify a fraction, that is, represent it as a fraction where the numerator and the denominator have no common divisors. it should read in the numerator and the denominator and then print out the fraction in its simplified form. I tried to calculate it with: while n!=0 { r = m mod n; m = n; n = r;
2
3278
by: antar2 | last post by:
Hello, I am a beginner in python. following program prints the second element in list of lists 4 for the first elements in list 4 that are common with the elements in list 5 list4 = ,,] list5 =
4
3475
by: jmf777 | last post by:
Hi I'm trying to write a program to find the greatest common divisor of 2 numbers input by the user. This is what I got so far: #include <stdio.h> int gcd(int a, int b); int main(void) {
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10351
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10096
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9174
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5534
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.