class Demo8
{
public static void main(String[] args)
{
//有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13...求出这个数列的前20项之和
int sum = 0,zi = 2,mu = 1,t;
sum = sum+zi/mu;
for(int i=1;i<=19;i++)
{
t = zi;
zi = zi+mu;//3
mu = t;//2
sum = sum+zi/mu;
}
System.out.println("sum="+sum);
}
}
{
public static void main(String[] args)
{
//有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13...求出这个数列的前20项之和
int sum = 0,zi = 2,mu = 1,t;
sum = sum+zi/mu;
for(int i=1;i<=19;i++)
{
t = zi;
zi = zi+mu;//3
mu = t;//2
sum = sum+zi/mu;
}
System.out.println("sum="+sum);
}
}