标签:div out print span ati string log author nbsp
/** * @author 有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13...求出这个数列的前20项之和。 */ public class Sum { public static void main(String[] args) { double a = 1, b = 1, c = 0, s = 0; for (int i = 0; i < 20; i++) { c = a + b; s = s + c / a; b = a; a = c; } System.out.println(s); } }
有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13...求出这个数列的前20项之和。
标签:div out print span ati string log author nbsp
原文地址:http://www.cnblogs.com/lanseyitai1224/p/7011531.html