蓝桥杯 算法训练 6-1 递归求二项式系数值
程序员文章站
2022-06-06 20:55:05
...
import java.util.Scanner;
public class Main {
public static int digui(int n , int k) {
if(n == k || k == 0) {
return 1;
}
return digui(n-1,k) + digui(n-1,k-1);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int k = sc.nextInt();
int n = sc.nextInt();
System.out.println(digui(n,k));
}
}