We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
class Solution
{
static void Main(string[] args)
{
int t = Convert.ToInt32(Console.ReadLine());
while (t-- > 0)
{
int n = Convert.ToInt32(Console.ReadLine());
BigInteger pow = BigInteger.One;
for (int i = 1; i <= n; i++)
{
pow = BigInteger.Multiply(pow, new BigInteger(2));
}
int sum = 0;
while (pow > 0)
{
BigInteger d = pow % 10;
sum += (int)d;
pow /= 10;
}
Console.WriteLine(sum);
}
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #16: Power digit sum
You are viewing a single comment's thread. Return to all comments →
In C# :
using System; using System.Numerics;
class Solution { static void Main(string[] args) { int t = Convert.ToInt32(Console.ReadLine());
}