#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;
}

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 = gcd(num1, num2);
    cout << "NWD(" << num1 << ", " << num2 << ") = " << result << endl;

    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: