#K50647. Fibonacci Sequence Generator
Fibonacci Sequence Generator
Fibonacci Sequence Generator
You are given a positive integer n. Your task is to generate and print the first n numbers of the Fibonacci sequence. The Fibonacci sequence is defined as follows:
\(F(0)=0,\ F(1)=1\) and for \(n \geq 2\), \(F(n)=F(n-1)+F(n-2)\).
For example, when n = 5
, the sequence is: 0 1 1 2 3
.
Input will be provided via stdin and output should be printed to stdout.
inputFormat
The input consists of a single integer n
(1 ≤ n ≤ 50
), which denotes the number of terms of the Fibonacci sequence to generate.
outputFormat
Print the first n
Fibonacci numbers separated by a single space.
1
0