|
INTERVIEW QUESTIONS
PROGRAMMING LANGUAGES
HTML
DETAILS
Question: Write a program to find the L.C.M. and G.C.D.of two numbers?
Answer: int gcd(int a, int b) { if (a==0 && b==0) return -1; if (b==0) return a; return gcd(b,a%b); }
int lcm (int a, int b) { return (int) (a*b)/gcd(a,b); }
|
|
|
Category |
HTML Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 9742 users |
Added on |
9/9/2013 |
Views |
68075 |
Rate it! |
|
|
Question:
Write a program to find the L.C.M. and G.C.D.of two numbers?
Answer:
int gcd(int a, int b) { if (a==0 && b==0) return -1; if (b==0) return a; return gcd(b,a%b); }
int lcm (int a, int b) { return (int) (a*b)/gcd(a,b); } Source: CoolInterview.com
Answered by: Nutan | Date: 9/11/2008
| Contact Nutan
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All HTML Interview Questions & Answers - Exam Mode /
Learning Mode
|