#C14937. Fibonacci Sequence and Nth Term

    ID: 44641 Type: Default 1000ms 256MiB

Fibonacci Sequence and Nth Term

Fibonacci Sequence and Nth Term

This problem requires you to compute two results based on the Fibonacci sequence. Given a non-negative integer \(n\), you need to output:

  • The first \(n\) Fibonacci numbers, where the Fibonacci sequence is defined as \(F(0)=0, F(1)=1\) and for \(n \ge 2\), \(F(n)=F(n-1)+F(n-2)\). Note that when \(n=0\), the sequence is empty and when \(n=1\), the sequence contains only \(0\).
  • The \(n\)th Fibonacci number, where by definition \(F(0)=0, F(1)=1, F(5)=5,\) etc.

For example, if \(n=5\), the first 5 Fibonacci numbers are: 0, 1, 1, 2, 3 and the 5th Fibonacci number is 5.

inputFormat

The input consists of a single non-negative integer \(n\) provided via standard input.

Examples:

  • 0
  • 1
  • 5
  • 10

outputFormat

The output should contain two lines:

  • The first line displays the first \(n\) Fibonacci numbers separated by a single space. If \(n=0\), output an empty line.
  • The second line displays the \(n\)th Fibonacci number.

Note: Use standard output to print your results.

## sample
0

0

</p>