#include <iostream>
using namespace std;
// Funkcja do obliczania NWD (największy wspólny dzielnik) za pomocą algorytmu Euklidesa
int gcd(int a, int b) {
while (b != 0) {
int temp = b;
b = a % b;
a = temp;
}
return a;
}
// Funkcja do obliczania NWW (najmniejsza wspólna wielokrotność)
int lcm(int a, int b) {
return abs(a * b) / gcd(a, b);
}
int main() {
int num1, num2;
cout << "Podaj dwie liczby całkowite: ";
cin >> num1 >> num2;
if (num1 <= 0 || num2 <= 0) {
cout << "Liczby muszą być większe od zera." << endl;
return 1;
}
int result = lcm(num1, num2);
cout << "NWW(" << num1 << ", " << num2 << ") = " << result << endl;
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: