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?Linke a Ninja
I think using properties of the object (result-array) is much more obvious and understandable by other developers. There is no risk of changes of the length after creating the array (and if it would change you wouldn't have the threat of missing it), where 'n' could be used for something else in between the array creation and the population of the array.
mine was the same except that I used 'n' instead of result.Length