1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
OLga [1]
3 years ago
12

Implementations in c++ programming when finding lcm and gcd in c++​

Computers and Technology
1 answer:
vazorg [7]3 years ago
7 0

Answer:

#include<iostream>

using namespace std;

int lcm(int m, int n) {

  int a;

  a = (m > n) ? m: n;

  while (true) {

     if (a % m == 0 && a % n == 0)

        return a;

        ++a;

  }

}

int gcd(int m, int n) {

  int r = 0, a, b;

  a = (m > n) ? m : n;

  b = (m < n) ? m : n;

  r = b;

  while (a % b != 0) {

     r = a % b;

     a = b;

     b = r;

  }

  return r;

}

int main(int argc, char **argv) {

  cout << "Enter the two numbers: ";

  int m, n;

  cin >> m >> n;

  cout << "The LCM of two numbers is: " << lcm(m, n) << endl;

  cout << "The GCD of two numbers is: " << gcd(m, n) << endl;  

  return 0;

}

Explanation:

You might be interested in
During the Cold War, defense contractors were required to shield sensitive computing systems and prevent electronic eavesdroppin
mart [117]

Answer:

Tempest

Explanation:

3 0
3 years ago
A pointing device controls the movement of the ____.
andrey2020 [161]
<span>A pointing device controls the movement of the </span>Mouse Pointer
3 0
3 years ago
If the ____________ is broken on a laptop, chances are other parts are also broken.
ella [17]
Central processing Unit
8 0
3 years ago
To copy the formatting of selected text to another place in the document use _____.
ANEK [815]
To copy the formatting of selected text to another place in the document use the paintbrush AKA. Format painter
7 0
3 years ago
Does any of yall know how to delete your account?
il63 [147K]

Answer:

No i really don't but why would you want to delete your account

8 0
2 years ago
Other questions:
  • 50+ POINTS AND BRAIN IF CORRECT Chris is working with other employees on a worksheet. The other employees have made comments, bu
    8·1 answer
  • What Event is called when an Object collides with an non-trigger collider?
    13·1 answer
  • Which is not an example of a lighter-than-air gas?
    5·2 answers
  • What is the binary answer to the binary number 100 added to the binary number 11?
    14·2 answers
  • What is anatomy of software house?
    10·1 answer
  • Which statement is true of Web-based social media?
    12·1 answer
  • Why is it NOT a good practice to save everything on the desktop?
    6·2 answers
  • In which of the following scenarios would you choose to embed versus import data?
    8·1 answer
  • Describe all the steps a router goes through while deciding where to send the a packet. Explain why a router would choose one ro
    7·1 answer
  • What is a file path?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!