public class TestCalc {
public static void main(String[] args) {
int n = 10;
System.out.println("1到"+n+"的立方和为"+calculation(n));
}
public static int calculation(int n) {
int result = 0;
for(int i=1; i<=n; i++) {
result += cube(i);
}
return result;
}
public static int cube(int num) {
return num*num*num;
}
}