.net - Calculate factorials in C# -


how can calculate large factorials using c#? windows calculator in win 7 overflows @ factorial (3500). programming , mathematical question interested in knowing how can calculate factorial of larger number (20000, may be) in c#. pointers?

[edit] checked calc on win 2k3, since recall doing bigger factorial on win 2k3. surprised way things worked out.

  1. calc on win2k3 worked big numbers. tried !50000 , got answer, 3.3473205095971448369154760940715e+213236

  2. it fast while did this.

the main question here not find out appropriate data type, bit mathematical. if try write simple factorial code in c# [recursive or loop], performance bad. takes multiple seconds answer. how calc in windows 2k3 (or xp) able perform such huge factorial in less 10 seconds? there other way of calculating factorial programmatically in c#?

have @ biginteger structure:

http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx

maybe can implement functionality.

codeproject has implementation older versions of framework @ http://www.codeproject.com/kb/cs/biginteger.aspx.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -