/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
 */
package javaapplication7;

import java.util.Scanner;

/**
 *
 * @author mateo
 */
public class Konsolowa {

    /*
    **********************************************
    nazwa funkcji: NWD
    opis funkcji: zwraca najwiekszy wspolny dzielnik liczby a i b
    parametry: a - jedna liczba to wyznaczenia NWD
               b - druga liczba to wyznaczenia NWD
    zwracany typ i opis: liczba calkowita - najwiekszy wspolny dzielnik liczby a i b
    autor: 31232412412
    ***********************************************
    */
    
    public static int NWD(int a, int b) {    
       
        while(a != b) {
            if(a > b) {
                 a = a-b;
            } 
            
            if(b>a) {
                b = b-a;
            }
        }
        
        
        return a;
    }
    
    public static void main(String[] args) {
        int a, b;
        Scanner sc = new Scanner(System.in);
        
        System.out.println("Podaj a: ");
        a = sc.nextInt();
        System.out.println("Podaj b: ");
        b = sc.nextInt();
        
        System.out.println("NWD("+a+", "+ b + ") = " + NWD(a,b));
    }
    
}
