Chap 2
实践2-1
class Ex2_1{
public static void main(String[] args) {
float sum=0.0f,count=1.0f;
for(int i=1;i<=20;++i){
count=1.0f;
for(int j=1;j<=i;++j)
count*=j;
sum+=count;
}
System.out.println("1+2!+3!+...+20!的值为:"+sum);
}
}
实践2-2
public class Ex2_2{
public static void main(String[] args) {
System.out.println("** 菲波拉挈数列的前20个数为:**");
long f1 = 1, f2 = 1;
for (int i = 1; i <= 10; i ++) {
System.out.print(f1 + " " + f2 + " ");
if (i %