#C14612. Fibonacci Sequence Generator
Fibonacci Sequence Generator
Fibonacci Sequence Generator
This problem requires you to generate the first n numbers of the Fibonacci sequence.
The Fibonacci sequence is defined as follows:
\(F(0)=0, \quad F(1)=1,\)
and for all \(n \geq 2\),
\(F(n)=F(n-1)+F(n-2).\)
Your program should read a single input from stdin representing a positive integer \(n\) and output the first \(n\) Fibonacci numbers separated by a single space on stdout. If the input is not a positive integer, your program must output the following error message exactly:
Error: Input must be a positive integer.
Please ensure that your solution handles invalid inputs gracefully.
inputFormat
The input consists of a single line containing a value \(n\), which is supposed to be a positive integer.
For example:
5
outputFormat
If the input \(n\) is a positive integer, output the first \(n\) Fibonacci numbers separated by a space. Otherwise, output Error: Input must be a positive integer.
For example, if the input is:
5
The output should be:
0 1 1 2 3## sample
5
0 1 1 2 3