package Text; public class Sumn {
public static void main (String args[]){
System.out.println("整数和");
Sum S=new Sum();
S.prient();
System.out.println("偶数和");
sum1 s1=new sum1();
s1.prient();
System.out.println("N!");
sum2 s2=new sum2();
s2.prient();
System.out.println("Fibonacci数列的前N项");
sum3 s3=new sum3();
s3.prient();
} }
package Text; public class Sum { public int sum(int n){ int x=0;
for(int i=1;i<=n;i++){
x=x+i;
}
int s=x;
return s;
}
public void prient(){
System.out.println(sum(100));
} } package Text; public class sum2 {
public int sum(int n){ int x=1;
for(int i=1;i<=n;i++){
x=x*i;
}
int s=x;
return s;
}
public void prient(){
System.out.println(sum(10));
} }
package Text;
public class sum3 {
int [] intfib=new int[20];
public void prient(){
int i;
int n= 20;
for(i=1;i<=n;i++)
{
if(i==1)
intfib[0]=1;
else if(i==2)
intfib[1]=1;
else intfib[i-1]=intfib[i-2]+intfib[i-3];
System.out.print(intfib[i-1]+" ");
} } }
package Text; public class sum1 {
public int sum(int n){ int x=0;
for(int i=2;i<=n;i+=2){
x=x+i;
}
int s=x;
return s;
}
public void prient(){
System.out.println(sum(100));
} }