【第三周】第三章习题3.7
2016-09-15 21:40
330 查看
/*2016.9.15 * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** *编写一个应用程序求满足1+2!+3!……+N!《=9999的最大整数N * * @author 马康泰 */ public class Main { public static void main(String args[]){ int sum=0,fac=0; int n=1; Factorial a=new Factorial(); while(sum<=9999){ fac=a.factorial(n); sum=sum+fac; n++; } System.out.println(n); } } * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author 马康泰 */ public class Factorial { public int factorial(int i){//阶乘 int j,result=1; for(j=1;j<=i;j++){ result=result*j; } return result; } }
相关文章推荐
- C++primer第三章习题3.7
- 编程珠玑第三章习题3.7(5-8)
- 【第三周】第三章习题3.5
- 【第三周】第三章习题3.6
- 编程珠玑第三章3.7习题(1-4)
- 斯坦福大学(吴恩达) 机器学习课后习题详解 第三周 编程题 逻辑回归
- 数据库原理第三章习题作业
- Chapter5课后习题 “if”语句(第三周)
- 中级Perl 第三章课后习题
- C++面型对象程序 (电子工业出版社)设计课后习题第三章最后两题
- 《C++ Primer》第五版课后习题解答_第三章(1)(01-05)
- 《UNIX 网络编程》 第三章课后习题第三题
- c++ primer第五版(中文)习题答案 第三章第二节-标准库类型string
- java2 实用教程 第三版 第三章 习题 3
- C++Primer第三章习题(2)
- 概率图模型-原理与技术 第三章 贝叶斯网表示 习题与编程
- C++primer[习题][第三章][1-10]
- [詹兴致矩阵论习题参考解答]习题3.7
- 学习opencv 习题答案-第三章