#P104. Fibonacci sequence

Fibonacci sequence

題目描述

The Fibonacci Sequence is the series of numbers:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...

The next number is found by adding up the two numbers before it:

  • the 2 is found by adding the two numbers before it (1+1),
  • the 3 is found by adding the two numbers before it (1+2),
  • the 5 is (2+3),
  • and so on!

The recursion formula is : f(x) = f(x-1)+f(x-2)

Given a integer n, your task is to print out the first nFibonacci numbers

 

輸入格式

an integer n

1<n<50

輸出格式

a list of integers separated by a space represent the first n Fibonacci numbers

Samples

["5","7","10"]
["0 1 1 2 3","0 1 1 2 3 5 8","0 1 1 2 3 5 8 13 21 34 "]

原始資料

  • Zero1 題號:a104
  • Hydro 題號:Z0104
  • Locale:zh_TW
  • Display:open