Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- unsigned int a, b;
- cout << "Wpisz dwie liczby naturalne: ";
- cin >> a >> b;
- if (a == 0 || b == 0) {
- cout << "Te liczby nie posiadaja wspolnego dzielnika.\n";
- }
- else {
- auto x{ a }, y{ b }; // automatyczne przypisanie typu zmiennej
- while (x != y) {
- if (x > y) {
- x -= y;
- }
- if (y > x) {
- y -= x;
- }
- }
- cout << "Najwiekszym wspolnym dzielnikiem liczb " << a << " i " << b << " jest liczba " << x << ".\n";
- cout << "Najmniejsza wspolna wielokrotnoscia tych liczb jest " << a * b / x << ".\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement