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);
}
}
}
}
简单的斐波那契数列
最新推荐文章于 2019-07-24 17:08:00 发布