//C++版代码 #include <iostream> #include <numeric> using namespace std; int main() { int a, b; cin >> a >> b; cout << gcd(a, b) << endl; return 0; } //Java版代码 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); System.out.println(gcd(a, b)); } private static int gcd(int a, int b) { // return b == 0 ? a : gcd(b, a % b);//递归写法 //迭代写法 while (b != 0) { int temp = a % b; a = b; b = temp; } return a; } } #Python版代码 from math import gcd a, b = map(int, input().split()) print(gcd(a, b))