Java Programs
Fibonacci series in Java

public class FibonacciExample {
    public static void main(String[] args) {
        int n1 = 0, n2 = 1, n3, count = 15;
        System.out.print(n1 + " " + n2);
        for (int i = 2; i < count; i++) {
            n3 = n1 + n2;
            n1 = n2;
            n2 = n3;
            System.out.print(" " + n3);
        }
    }
}

运行结果
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377

参考资料

相关文章:

  • 2021-12-17
  • 2021-06-01
  • 2021-10-20
  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
  • 2021-06-23
  • 2021-06-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
  • 2021-12-30
  • 2021-11-15
  • 2021-09-09
  • 2022-01-19
相关资源
相似解决方案