testnestedloop.java
来自「由浅入深的介绍JAVAse的基本编程思想」· Java 代码 · 共 19 行
JAVA
19 行
public class TestNestedLoop{
public static void main(String args[]){
TestNestedLoop tn = new TestNestedLoop();
int total = tn.m(4); //1! + 2! + 3! + 4! = 33
System.out.println(total);
}
public int m(int n){
int result = 0;
for(int i=1; i<=n; i++){
int temp = 1;
for(int j=1; j<=i; j++){
temp *= j;
}
result += temp;
}
return result;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?