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.
I considered that before, but then it would lose some of the "spice" in the question. I wanted to get some number theory in the problem, but since I'm not a mathematician, it's hard for me to get correct answers eg. if you add up all postive and negative integers would it be 0 or NaN?
ZED.CWT, your approach makes sense but my approach makes sense as well, like I said I'm not a mathematician either so I'm not sure which one is correct.
I added in the description to return NaN if all integers would work as n to clear things up(and make things a little more boring).
Correct me if I am wrong
For both cases, new int[]{} and new int[]{x}, any integer would be able to work as n to satisfy the requirements. This means that we have to take the sum of all integers ranging from negative infinity to postive infinity. Taking the sum of all postive integers is postive infinity. Likewise, taking the sum of all negative integers is negative infinity. Postive infinity plus negative infinity is indeterminate, so NaN would best represent that.
Fixed it.
Interesting! Very nice!
This comment is hidden because it contains spoiler information about the solution