面试题:用10种方法实现1,1,2,3,5,8,13,21...序列的程序(已实现两种),答对加分(JAVA)

public class Main { /** * @param args */ public static void main(String[] args) { //1,1,2,3,5,8,13,21 int[] n = new int[8]; n[0] = 1; n[1] = 1; n[2] = 2; for(int i=1; i<7; i++) { n[i+1] = n[i-1] + n[i]; } for(int i : n) { System.out.println(i); } //1,1,2,3,5,8,13,21 int m = 0; int x = 1; int y = 1; for(int i=1; i<7; i++) { m = x + y; x = y; y = m; System.out.println(m); } }}其实这是一个公司出的面试题,如果做出来的话,月薪8000
2026年09月24日 23:14
有4个网友回答
网友(1):

斐波那契数列 Fibonacci数列

网友(2):

God closed a leafed door for you to open a leaf of window inevitably for you

网友(3):

11
10
2

网友(4):

一道题每月800呢