## CCO '98 P1 - Fibonacci Numbers

View as PDF

Points: 10
Time limit: 1.0s
Memory limit: 64M

Problem type
Allowed languages
C, C++, ObjC, Pascal
##### Canadian Computing Competition: 1998 Stage 2, Day 1, Problem 1

The th Fibonacci number, , is defined thus:

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

#### Sample Input

1
2
3
4
5
100
0

#### Sample Output

1
1
2
3
5
354224848179261915075

## Comments

• commented on Dec. 27, 2019, 11:11 a.m. edit 2

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Jan. 6, 2020, 9:23 p.m.

Tough luck chief better luck next time :)

• commented on Dec. 27, 2019, 11:30 a.m.

The test data is correct. You are seeing a value of 2 because the output is clipped.

• commented on Jan. 8, 2020, 11:09 a.m.

Ok, Thanks!

• commented on June 8, 2019, 12:23 p.m.

Sorry I just checked again I have a few issues I just found.

• commented on June 6, 2019, 9:34 a.m.

Why does the judge keep saying my answer is wrong even though it works on repl.it

• commented on June 6, 2019, 10:38 a.m.

Your answers are incorrect for (somewhat) large values of .

• commented on June 8, 2019, 12:18 p.m. edited

I have double checked the numbers my program is outputting and they are exactly correct. Also, the judge fails me for a relatively low value of fib(20).

• commented on Sept. 18, 2019, 8:24 a.m.

I think the submission feedback is troncated, displaying only the first elements (even if they are correct).

I had a similar error for very big results, but I had the same reaction, fib(20) being the last line displayed in feedback, while I was sure it was working for this input.

Maybe verify very big results (like 200) using a webgenerator for fibonaccis number.

• commented on Sept. 18, 2019, 4:05 p.m.

The issue AryanG had was actually related to how the answers were stored. In C++, long double is definitely not precise enough to store the correct answers for large values of .