zhang_yan6

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

题目:编写一个Java程序在屏幕上输出1!+2!+3!+??+10!的和。

package demo;

 

public class Demo {

    public static void main(String[] args) {

       int jc = getJc(5);

       System.out.println(jc);

    }

    public static int getJc(int num){

       int result = 1;

       if(num > 1){

           result = num * getJc(num -1);

       }

       return result;

    }

      

   

posted on 2018-11-23 16:23  zhang_yan6  阅读(1387)  评论(0)    收藏  举报