蓝桥杯 基础练习 Fibonacci数列
作者:互联网
问题描述
Java 代码实现
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int a = 1;
int b = 1;
int sum = 1;
if (n < 3) {
System.out.println(1);
} else {
for (int i = 3; i <= n; ++i) {
sum = (a+b)%10007;
a = b;
b = sum;
}
System.out.println(b);
}
in.close();
}
}
标签:Java,数列,int,System,蓝桥,Fibonacci,public,Scanner 来源: https://www.cnblogs.com/Acx7/p/15824834.html