题解 | #牛牛的排列数#
牛牛的排列数
http://www.nowcoder.com/practice/9ca1c236cdbf46da9e08e1f510808625
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); System.out.println(func(n,m)); } // 找到递归的规律(例子):A(9,4) = 9*A(8,3) = 9*8*A(7,2) = .... public static int func(int n, int m){ if(m == 1){ return n; } return n*func(n-1,m-1); } }