CCO '98 P1 - Fibonacci Numbers

View as PDF

Submit solution

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 64M

Problem type
Allowed languages
Brain****, C, C++, Pascal, Rust
Canadian Computing Competition: 1998 Stage 2, Day 1, Problem 1

The nth Fibonacci number, f(n), is defined thus:

{f(1)=1f(2)=1f(n)=f(n1)+f(n2)for all n>2

Write a program that reads several n, one per line, and writes the corresponding f(n), one per line. Each value of n will be between 1 and 200. The last line of input contains 0.

Sample Input

Copy
1
2
3
4
5
100
0

Sample Output

Copy
1
1
2
3
5
354224848179261915075

Comments

There are no comments at the moment.