import java.util.*; public class Main { public static Scanner sc = new Scanner(System.in); static int gcb(int m, int n){ if(n > m){ int tmp = m; m = n; n = tmp; } return m % n == 0 ? n : gcb(n, m % n); } public static void main(String[] args) { int m = sc.nextInt(); int n = sc.nextInt(); int gcb = gcb(m, n); System.out.println(gcb); } }
import java.util.*; public class Main { public static Scanner sc = new Scanner(System.in); static int gcb(int m, int n){ if(n > m){ int tmp = m; m = n; n = tmp; } int r = m % n; while (r != 0){ m = n; n = r; r = m % n; } return n; } public static void main(String[] args) { int m = sc.nextInt(); int n = sc.nextInt(); int gcb = gcb(m, n); System.out.println(gcb); } }