求最大公约数
代码:
import java.util.Scanner; public class 第十三题 { public static void main(String[] args) { /* Scanner sc=new Scanner(System.in); int a=sc.nextInt(); int b=sc.nextInt(); while (b!=0){ int c=a%b; a=b; b=c; } System.out.println(a);*/ Scanner sc=new Scanner(System.in); int a=sc.nextInt(); int b=sc.nextInt(); int w= ff(a,b); System.out.println(w); } public static int ff(int a,int b){ if(b==0){ return a; } int c=a%b; a=b; b=c; return ff(a,b); } }