Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Nope. First number is 1
This comment is hidden because it contains spoiler information about the solution
Hello. I think you're wrong and you got overflow. Because Fibonacci's sequence can't take negative value. It begins with 1, 1, 2, 3, 5, 8... and so on.
You have negative value, because value in 300th is "222232244629420445529739893461909967206666939096499764990979600" this value bigger than types integer or long can store (maybe BigInteger or BigDecimal, but I haven't tested it).
In Java or C/C++, for example, sign integer type (32 bit) max value is: 2147483647.
signed long (long long in C/C++) type (64 bit) max value is: 9223372036854775807 (note that signed 64 bit is smaller than 300th Fibonacci number). What happens if give more than can be stored?
If I'll try making something like this in Java:
I will get overflow, in this case "i" will store "-2147483648". Why "-2147483648", not "2147483647"? Because the first bit is responsible for the sign.
You can read more about signed/unsigned numbers here and here
I did not realize, what it affect, but I swapped 'expected' and 'actual'.
Replaced test cases from static to random values.