//记得崩坏2里面一把手枪用过跟这个这个类似的算法。
//转载标明出处,禁止商业转载。
//搞清楚原理再使用。
package math;
public class math {
public static void main(String[] args) {
long a=1,b=1,c = 0,d=0;
while ( a <= 4000000 || b <= 4000000) {
c = a + b;
a = b;
b = c;
if(b%2==0) {
d+=b;
}
}
System.out.println(d);
}
java:兔子算法
最新推荐文章于 2022-03-31 22:41:44 发布