package com.javarush.task.task14.task1420;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
НОД
*/
public class Solution {
public static void main(String[] args) throws Exception {
int a = 2;
int b = 1;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
a = Integer.parseInt(reader.readLine());
b = Integer.parseInt(reader.readLine());
}catch (ArithmeticException e){
System.out.println(e);
}
System.out.println(gcd_3(a, b));
}
public static int gcd_3(int a, int b) {
while (a != b) {
if (a > b) {
a = a - b;
} else {
b = b - a;
}
}
return a;
}
}
package com.javarush.task.task14.task1420;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
НОД
*/
public class Solution {
public static void main(String[] args) throws Exception {
int a = 2;
int b = 1;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
a = Integer.parseInt(reader.readLine());
b = Integer.parseInt(reader.readLine());
}catch (ArithmeticException e){
System.out.println(e);
}
System.out.println(gcd_3(a, b));
}
public static int gcd_3(int a, int b) {
while (a != b) {
if (a > b) {
a = a - b;
} else {
b = b - a;
}
}
return a;
}
}