473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

[Merged] find gcd of 2 numbers

5
can anyone give me a code to this programm pllllz i need it.

Write a program that computes the Greatest Common Divisor (GCD) of two positive integers m and n entered by the user (assume that m >= n).

GCD: is the largest positive number that exactly divides both m and n.
Mar 25 '07 #1
8 2754
Savage
1,764 Expert 1GB
We are not allowed to give you a code,but we can help you write it and to give you some hints.

So to find a GCD you need two variables.One will take a value of larger and secound of smaller number.

Than you need a while loop that will only execute if smaller number is non-zero
number.

For example:

j-smaller number

i-larger number

k-this will represent modulo

Expand|Select|Wrap|Line Numbers
  1. while(j!=0)
  2. {
  3.               k=i%j;
  4.               i=j;
  5.               j=k;
  6. }
  7. GCD=i;
Savage
Mar 25 '07 #2
soosoo
5
thx for ur help
Mar 25 '07 #3
soosoo
5
hello can i know what is worong with my code

**code snipped**
Mar 27 '07 #4
RedSon
5,000 Expert 4TB
The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

Please read the Posting Guidelines and particularly the Coursework Posting Guidlines.

Then when you are ready post a new question in this thread.

MODERATOR
Mar 27 '07 #5
RedSon
5,000 Expert 4TB
You must have a pointed question. You cannot just paste all of your code and say "someone tell me what is wrong".
Mar 27 '07 #6
Savage
1,764 Expert 1GB
Hi,

soosoo.

Is the explanation and example which I gave to you

here was

helpfull?.


Savage.
Mar 27 '07 #7
RedSon
5,000 Expert 4TB
Double posting is also an infringement upon the guidelines in the FAQ. Please read the entire FAQ before posting again. Threads have been merged.
Mar 27 '07 #8
RedSon
5,000 Expert 4TB
If you want to calculate the GCD of two numbers you need to break down your problem into the steps necessary. When you calculate a GCD on paper how do you do it? What are the steps involved?
Mar 27 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Piotr | last post by:
Is there any way to split all merged words but www and e-mail addresses? I have regexp preg_replace("/(\.)(])/", "\\1 \\2", "www.google.com any,merged.words mymail@domain.com") it give me...
19
by: rbt | last post by:
Here's the scenario: You have many hundred gigabytes of data... possible even a terabyte or two. Within this data, you have private, sensitive information (US social security numbers) about your...
1
by: NeilAnderson | last post by:
Hi Could anybody point me in the direction of some info about emailing merged word word documents. I have a word document that is merged with a query which I want to email to about seventy...
8
by: jquest | last post by:
Hi Again; I have had help from this group before and want to thank everyone, especially PCDatasheet. My database includes a field called HomePhone, it uses the (xxx)xxx-xxx format to include...
5
by: Brian Henry | last post by:
I have a form with a main menu on it (mdi parent form) and i have a child form with a menu and I am mergeing the menus together for the menu called reports.. now when i do this they merge just...
0
by: marfi95 | last post by:
Does anyone know if its possible using the standard controls shipped with vb.net, if its possible to create a listview with merged cells. By merged cells, I'm referring to basically what can be...
0
by: jamesmc | last post by:
I recently upgraded a Web Site project to the new 'Web Application' project (Beta V2 Preview) and also using the preview deployment project. Everything is working fine, but I am getting the...
1
by: MAdcock | last post by:
Hi, I have written some code to create a copy workbook of another sheet in a workbook, but the outcome is that the copy has links (='Sheet1'!A5) for example instead of the values contained within...
2
by: riwar | last post by:
Hello. Anybody knows how to clear merged cells using c#? If i try to do this via ...Cells.get_Range(x,x).ClearContents(); compiler say that there is no possibility to operate with this method on...
1
by: mymoup | last post by:
hi, all. I want to verify data merged from access in sqlserver.but it has too many records .so i need a tool do this. someone maybe has it. thanks
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.