public class Test { public static void main(String[] args) { int n = 5; //项目数 long n1 = 1, n2 = 1; for (int i = 3; i <= n; i++) { n2 = n1 + n2; n1 = n2 - n1; } System.out.println(n2); } }
数列1,1,2,3,5,…(从第三项开始每一项是前两项之和
最新推荐文章于 2022-12-26 13:50:17 发布