package com.hanqi; public class Qiuhe { public static void main(String[] args) { // TODO 自动生成的方法存根 double sum=0,fenshu=0,a=1,b=2,c=0; for (int i = 0; i < 20; i++) { fenshu=b/a; c=a; a=b; b=a+c; sum+=fenshu; //System.out.println(fenshu); } System.out.println("前20项之和为"+sum); } }