📄 testnestedloop.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -