题解 | #函数实现计算一个数的阶乘#
函数实现计算一个数的阶乘
http://www.nowcoder.com/practice/df78ded035574202945d077cb619d0e7
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.println(fact(sc.nextInt()));
}
public static long fact(int n){
if(n==1){
return 1;
}else{
return (long)n*fact(n-1);
}
}
}
