#C14355. Fibonacci Sequence Generator
Fibonacci Sequence Generator
Fibonacci Sequence Generator
You are given an integer n
as input. Your task is to generate the first n
terms of the Fibonacci sequence and print them to standard output, separated by a single space.
The Fibonacci sequence is defined as follows:
\(F_0 = 0\), \(F_1 = 1\) and for every \(n \ge 2\), \(F_n = F_{n-1} + F_{n-2}\).
If the given integer is less than or equal to 0, print nothing.
Examples:
- Input: 5 Output: 0 1 1 2 3
- Input: 1 Output: 0
- Input: 10 Output: 0 1 1 2 3 5 8 13 21 34
inputFormat
The input consists of a single integer n
provided via standard input.
outputFormat
The output should be the first n
Fibonacci numbers printed in a single line and separated by a single space. If n ≤ 0
, print nothing.
5
0 1 1 2 3