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.
Right. JS math is fairly buggy - in this case the function will round only when given 9 thousandths. I have no guess as to why it even rounds, but it seems to be different per browser.
Try more edge cases, like 0.145 which should produce 0.15, but fails and returns 0.14 (I checked in Chrome concole).
For
n = 0
code will return 8, but it should be 4.Also as far as I see you do not need to keep all values, you need only previous two.
Result for
n == 0 || n == 1
is wrong, it should be 4.You also do not need
Aggregate
, you could calculate sum withinfor
cycle.