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.
Like the others have said before, is the solution good mathematical work. But in programming bad practice. For small n you can use it, but for greater n it would screem for a stack overflow.
The reason is that you call in each return the function nthfib for two times, which will be saved in the memory till you reach 1. At this point it bubbles back and return the addition from the retun statements.
This mess up the memory and crash your system.
An other solution, like mine, is the linear one where you loop up. With the use of one temporary int I can calculate the n-th fibonacci. The memory it´s also constant, in the inner loop you use constantly three int with each 4 Byte = 12 Byte. This isn´t much.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Could you please share the link where I can read more about this solution)
I like this one. Very functional and easy to read.
Obviously this is best practice
You have a missing semicolon
@alexschrod awesome answer, thank you for explaining so succinctly
dang and I thought mine is simple enough
Problem with this solution is that it is O(n) and solution can be O(1)
Same decision :)
This comment is hidden because it contains spoiler information about the solution
I know this is old, but can someone explain where the s comes into play?
I know the left side s is the parameter but the right side s is what is returned, but how does that return if the vale is true if there is only the parameter.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Loading more items...