.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.
calc on win2k3 worked big numbers. tried !50000 , got answer, 3.3473205095971448369154760940715e+213236
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
Post a Comment