请大神看看,为什么程序运行结果和计算器计算结果不一样?
求2/1+3/2+5/3+8/5+13/8=?
public class HelloWorld {
public static void main(String[] args) {
double sum = 0.0;
double fz = 2.0;
double fm = 1.0;
for(int i = 0; i <= 5; i ++){
sum += (fz / fm);
fm = fz;
fz += fm;
}
System.out.println("sum:"+sum);
}
}