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
Discussion Topic
frozen [14]

The advantages of using spreadsheets for managing personal finances is that:

  • Spreadsheets are known to be tools that are very quick and easy and helps one to add into a workflow.
  • Spreadsheets are regarded as an efficient tools for financial documents. A person can have access to a lot of spreadsheet templates and they can be able to visualize data along with caveats.

<h3>What is the advantage of using a spreadsheet?</h3>

The Advantage is that it is one that help[s a person to be able to organizing a lot of data.

Note that The advantages of using spreadsheets for managing personal finances is that:

  • Spreadsheets are known to be tools that are very quick and easy and helps one to add into a workflow.
  • Spreadsheets are regarded as an efficient tools for financial documents. A person can have access to a lot of spreadsheet templates and they can be able to visualize data along with caveats.

Learn more about spreadsheets  from

brainly.com/question/26919847

#SPJ1

6 0
1 year ago
The term that refers to the standard computer language for creating web pages is called:
Pavel [41]

Answer:

Language programming Web's programming language

Explanation:

6 0
3 years ago
Customer A with a Bronze service level package calls in a Critical System Failure at 9:00 AM. Customer B with a Silver service l
inysia [295]
This question depends on what the service level packages have to offer as an agreement. Does this question come with a list of what the service levels have to offer?
4 0
3 years ago
What type of device is characteristic of an enterprise environment?
Nitella [24]
A workstation used at an engineering firm.
8 0
3 years ago
Can file extension txt be used in other os
rodikova [14]
Yes, a text file with a .txt extension can be read by Linux/Unix/Mac as they are ASCII unformatted.
6 0
3 years ago
Other questions:
  • Image files are grouped into two categories: _____.
    5·1 answer
  • A tornado may be approaching if you observe which of the following?
    15·1 answer
  • Henry Ford would have been most interested to bring which modern innovation to his automotive factories?
    5·2 answers
  • Which of the following types of access controls do not describe a lock? (a)- Directive (b)- Physical (c)- Preventative (d)- Dete
    8·1 answer
  • On an open book test, Anna was asked to predict how American laws may affect the Mexican way of life if the US Constitution was
    15·1 answer
  • The moon has less mass than the earth, so what happens to objects on the moon?
    11·1 answer
  • Why are computers complicated?
    15·1 answer
  • Fill in the blanks Pasaline could ----- and ------- very easily.​
    8·1 answer
  • What are the benefits and risks of a client-server network?
    5·1 answer
  • you are packing a mobile phone containing a lithium ion battery and you get a prompt on the screen to put a lithium ion label on
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!