Self-hatred

Project Euler Problem #20

using System;
using System.Numerics;

public class Twenty
{
	static void Main()
	{
		BigInteger 	a = 100;
		string 		b;
		int 		c = 0;

		for (int i = 99; i >= 1; i--)
			a *= i;
		
		b = Convert.ToString(a);

		for (int i = 0; i < b.Length; i++)
			c += b[i] - '0';

		Console.WriteLine("\n{0}\n", c); 
	}
}

Categorised as: programming


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>