The System.Numeric.BigInteger class allows for calculating VERY LARGE values.
I created a sample window form app to calculate the factorial of an input value
private void button1_Click(object sender, EventArgs e)
if (int.TryParse(this.textBox1.Text, out inputValue) && inputValue > 0)
BigInteger bigInt = 1;
while (inputValue > 1)
bigInt = BigInteger.Multiply(inputValue--, bigInt);
label1.Text = bigInt.ToString();
label2.Text = bigInt.ToString().Length + " Digits";
label1.Text = "Invalid Input";
label2.Text = "";
just so you know, 1000! has 2568 digits
Matthew works on improving the performance and experience of the Code Project site for users, clients, and administrators.
Matthew has more years of software develeopment, QA and architecture experience under his belt than he likes to admit. He gradutated for the University of Waterloo with a B.Sc. in Electrical Engineering. He started out developing micro-processor based hardware and software including compilers and operating systems.
His current focus is on .NET web development including jQuery, Webforms, MVC, AJAX, and patterns and practices for creating better websites.
He is the author of the Munq IOC
, the fastest ASP.NET focused IOC Container.
His non-programming passions include golf, pool, curling, reading and building stuff for the house.