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.
Works but too long !
Because you try to assig int to BigInteger. i variable is int, and Math.Pow(2, i) also returns int.
I did the almost the same thing as you did
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?Great! But this task can be solved without Linq. Good luck!