简单的斐波那契数列
2017-08-23 15:42
351 查看
package com.sq.test; import java.util.Scanner; public class Test2 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int count = input.nextInt(); int a = 0; int b = 1; boolean is = true; if(count==0){ System.out.println(0); }else if(count==1){ System.out.println(1); }else{ for(int i = 2;i<=count;i++){ if(i%2==0){ a=a+b; is = false; }else{ b=a+b; is = true; } } if(is){ System.out.println(b); }else{ System.out.println(a); } } } }
相关文章推荐
- 斐波那契数列在php中的简单实现
- java 实现最简单的斐波那契数列
- python实现最简单斐波那契数列
- 简单算法题二(哥德巴赫猜想、斐波那契数列)
- 【计蒜客简单题】斐波那契数列
- NYoj 252 01串[简单动态规划+组合数+斐波那契数列]
- [网易2012年某笔试题] 求斐波那契数列, 要求时间复杂度尽可能小(简单题,不熟悉斐波那契的同学可参考)
- 简单递归—斐波那契数列
- Nyoj 492 骨牌铺方格[简单动态规划||斐波那契数列]
- 汇编语言的简单入门--斐波那契数列(非递归)
- php实现斐波那契数列的简单写法
- php实现斐波那契数列的简单写法
- 用Python简单实现斐波那契数列
- 简单斐波那契数列实现
- 2013.12.27 泡面吧--简单的斐波那契数列
- 简单斐波那契数列
- python 简单的斐波那契数列
- 斐波那契数列的两种简单实现
- 简单的斐波那契数列程序
- python超简单实现斐波那契数列