我编写的是 1-10 的阶乘求和 ,如果是 1-100 的话 还要解决科学计数的问题(解决办法是使用字符串,具体的你可以从网上搜下)public class JieCheng { public static void main(String[] args)
{
int sum = 0;
for(int i=1;i<=10;i++){
int m = 1;
System.out.print(m);
for(int j =2 ; j<= i ; j++){
System.out.print("*" + j );
m *= j ;
}
sum += m ;
System.out.println("=" + m);
}
for(int k=1;k<=10;k++){
if(k==10){
System.out.print(k + "! = ");
}else{
System.out.print(k + "! + ");
}
}
System.out.print(sum);
}
}
public class Test1 {
public static double method1(int n) {
if (n == 1) {
return n;
} else {
return n * method1(n - 1);
} }
public static void main(String[] args) throws Exception {
System.out.println("一百的阶层:" + Test1.method1(100));
}}
public class Test {
public static void main(String[] args)
{
int m = 1;
int k = 1;
int sum = 0;
for(int i=0;i<100;i++)
{
m=k-m;
k+=m;
sum+=k;
System.out.print(k+" ");
}
System.out.println("");
System.out.println(sum);
}
}