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
Which virus-infecting components are email messages prone to carry?
Mrac [35]

Spam Messages

Explanation:

These are messages that contain malicious codes that are usually intended to send messages to the email user's email list without his permission.

Some are easily recognized with their subject but some come in the form of useful messages.

3 0
4 years ago
Read 2 more answers
Complete the following sentence.
dexar [7]

Answer:

arte digital es una forma de arte que utiliza principios de ingeniería como paleta.

Explanation:

8 0
2 years ago
What is the descriptor for a filter that warns or blocks you from potentially fraudulent or suspicious websites?.
algol [13]
A VPN. i believe what you’re referring to is called a vpn. it protects your data when you’re working online.
8 0
2 years ago
After you use the fill handle to copy cell contents, the quick copy options button appears, which can be used to fill the cells
Dimas [21]
After you use the fill handle to copy cell contents, the autofill options button appears, which can be used to fill the cells with only specific elements of the copied cell. The button <span>is a small square that appears in the bottom-right corner when you select a cell or range.</span>
7 0
3 years ago
What is the advantage of defining a target user?
spayn [35]
3) helps the designer develop a website tailored to the desired audience
4 0
3 years ago
Other questions:
  • What is a basic operation of computers
    13·1 answer
  • What file format is best for photo editing? Select one: a. JPG b. RAW c. DOC d. RTF
    12·2 answers
  • Use the Bisection Method to find the root 2. Write a main program and a function program 3. Main Program a. define constants b.
    9·1 answer
  • Write a program named SortWords that includes a method named SortAndDisplayWords that accepts any number of words, sorts them in
    10·1 answer
  • I need help. I wanna help a friend by giving him my powerpoint but I dont want him to steal my work. Is their anyway to restrict
    8·1 answer
  • Which of the following statements is true when it comes to developing a web presence for a business?
    6·1 answer
  • Write a code segment that will store a dinner selection in option1 based on the values of rsvp and selection. The intended behav
    5·1 answer
  • Create a Python script that will compare two (2) numbers entered by the user. Refer to the attached image and to the following a
    13·1 answer
  • A form of segmentation that is based on user usage rate, user status, purchase occasion, and benefits sought is _________.
    13·1 answer
  • Wi-Fi Protected Access (WPA) fixes critical vulnerabilities in the earlier wired equivalent privacy (WEP) standard. Understandin
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!