Link to home
Start Free TrialLog in
Avatar of John Esraelo
John EsraeloFlag for United States of America

asked on

SQL: Factorial:: large numbers

Hello team,
A non-recursive method in below will give me what I need, however, I would like to have a larger number than 38! and I know that either numeric or decimal can handle +- 38.  
Is there a way to use one of the 2 mentioned data types and use all the 72, not using the negative range?
(see attached)

Any assistance will be appreciated.
thx
factorial.png
ASKER CERTIFIED SOLUTION
Avatar of DcpKing
DcpKing
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Surendra Nath
Surendra Nath
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of John Esraelo

ASKER

I am aware of all the data types but appreciate your responses.
I might start looking into some calculations in other bases, such as hex or something.. then convert the result to a character string.
I think that if you are working with integers you might try converting all your numbers into right-justified, left-zero-filled varchars and then writing CLR functions in C# for adding, dividing, subtracting and multiplying. You might also search for articles on ASCII arithmetic and BCD.

Good luck!


Mike
This closed, but the number space of factorials is so small that you could just pre-compute them (or look them up) and store them in a table as strings.
Here they all are from 1 to 256
http://membres.multimania.fr/rsirdey/facttabl.htm
Just put those in the database and look them up. Don't bother doing all the math yourself.