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.
Well, the two possible values are -1 and 11:
In ruby, the result always have the same sign as the second operand (12 in this case) so it must be 11.
The resulting sign when doing modulus between negative numbers varies between different programming languages. There is a table in the right margin here that shows the chaos: http://en.wikipedia.org/wiki/Modulo_operation#Remainder_calculation_for_the_modulo_operation.
This is an example of recursion. The concept is present in many programming languages, and mathematics in general.
The equation for a single fibonacci number is dependent on the two previous fibonacci numbers (for all but n == 1 && n == 2). These are determined by either:
n
value that acts as a seed. These seed values are required to prevent infinite recursion, and are implemented as the following lines in this solution:For a ruby specific explanation of recursion, check out this StackOverflow Post.
For a more broad, mathematical explanation (including fibonacci numbers) see the wiki article on Recurrence relations.