import java.util.Scanner; public class suanfa { public static void main(String[] args) { Scanner in = new Scanner(System.in); int a = in.nextInt(); int b = in.nextInt(); int gcd=1; for ( int i = 2; i<=a && i<=b ; i++ ) { if ( a % i ==0 && b % i == 0 ) { gcd = i; } } System.out.println(a+"和"+b+"的最大公约数是"+gcd); } }
求m,n最大公约数方法
最新推荐文章于 2024-11-09 12:43:52 发布