Jump to content

[C++]Cel Mai Mic Multiplu Comun(CMMMC) a 2 numere


AIM Katzuno Valoare
 Share

Recommended Posts


#include <iostream>

using namespace std;

 

int main () {

int a, b, p;

cout<<"a=";

cin>>a;

cout<<"b=";

cin>>b;

p=a*b;//Calculam produsul numerelor initiale pentru a il folosii la cmmmc.

while (a!=b) {

if (a>b)

a=a-b;

else

b=b-a;

}

//Acum pt a descoperii cmmdc putem afisa una din valorile a si b

//Dar pt cmmmc vom folosi formula: a*b=cmmdc(a, b) * cmmmc[a, b]

 

cout<<"CMMMC="<<p/a<<endl;

return 0;

}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.