• 一个阶乘的递归小程序

public class Diguidiaoyong_jiecheng {    public static void main(String[] args) {        System.out.println("输入整数求阶乘:");        Scanner scanner = new Scanner(System.in);        int a = scanner.nextInt();        System.out.println(multiply(a));        scanner.close();    }    public static long multiply(int b) {        if(b=0)  return 1;//程序出口        else   return b*multiply(b-1);//multiply(b-1) 调用本身    }
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

TAG标签: 微信小程序递归

http://www.xiaochengxub.com/read-100413.html