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.
Because you try to assig int to BigInteger. i variable is int, and Math.Pow(2, i) also returns int.
or cast to BigInteger. (BigInteger) Math.Pow() is the same as BigInteger.Pow()
if n is int.MaxValue than stack overflow exception.=)
https://learn.microsoft.com/en-us/dotnet/api/system.numerics.biginteger.pow?view=net-7.0
Use BigInteger.Pow instead.
Isntead of
result[i] = (BigInteger)Math.Pow(2,i);
, I wroteresult[i] = Math.Pow(2,i);
and it threw an error. Why?The issue below is the same as this, closing.
Why this test return 0 instead of -3?
Kata.Sum(new List { 1, 1, 1 })
I substantially agree with Alex, and I do see harm in keeping this condition: there is already a mathematically sound return value for it in the usual rules. ( It'll be some negative number. ) It's a special case that prevents solvers from having to deal with empty sums ( which lots of people get wrong ). It's a missed chance to do it right and possibly teach people correct maths.
His packaging could have been more constructive, which might lead to better results for everybody, though.
Yes, let's have arbitrary requirements which contradict the task at hand and tell us to return a magic value which is impossible to differentiate from a normal function output
This is a suggestion at best. I see no harm in keeping this condition.
I saw what the problem was and I just fixed it. Thank you for your help.
Why? This requirement makes zero sense.
I see that you have, thanks, but they're not working correctly yet.
Random tests are insufficient.
Thank you for your feedback, I added some random tests now.
Loading more items...