Find the sum of digits in 100!
Problem:
n! means n × (n − 1) × … × 3 × 2 × 1
Find the sum of the digits in the number 100!
My Solution:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Euler
{
class Problem20 : IProblemBase
{
//n! means n × (n ? 1) × ... × 3 × 2 × 1
//Find the sum of the digits in the number 100!
public Problem20()
{
}
public string GetAnswer()
{
string result = "1";
int ret = 0;
long limit = 100;
List<long> ul = new List<long>();
for (long i = 1; i <= limit; i++)
{
result = Util.BigMulitply(result,i.ToString());
}
char[] c = result.ToString().ToCharArray();
for (int j = 0; j < c.Length; j++)
{
ret += Int32.Parse(c[j].ToString());
}
return ret.ToString(); ;
}
}
}