递归

 1 package com.pingfan.method;
 2 
 3 public class Demo3 {
 4     public static void main(String[] args) {
 5         System.out.println(f(5));
 6     }
 7     public static int f(int n){
 8         if(n==1){
 9             return 1;
10         }else {
11             return n*f(n-1);
12         }
13     }
14 }

 

posted @ 2021-03-26 22:01  HeartlessHero  阅读(23)  评论(0)    收藏  举报