#C13445. Fibonacci Sequence Generation
Fibonacci Sequence Generation
Fibonacci Sequence Generation
Given a non-negative integer n
, generate the first n
numbers of the Fibonacci sequence. The Fibonacci sequence is defined as follows:
\(F_0 = 0,\; F_1 = 1,\; \text{and} \; F_n = F_{n-1} + F_{n-2} \; \text{for} \; n \ge 2\).
If n
is less than or equal to zero, output an empty result.
Your program should read the input from standard input (stdin) and write the output to standard output (stdout).
inputFormat
The input consists of a single integer n
on a line by itself.
Example: 7
outputFormat
Output the first n
Fibonacci numbers, separated by a single space on one line. If n <= 0
, output an empty string.
Example output for input 7
: 0 1 1 2 3 5 8
1
0