ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   largest factorial that can be computed (https://www.excelbanter.com/excel-programming/337196-largest-factorial-can-computed.html)

Loane Sharp[_2_]

largest factorial that can be computed
 
Hi there

I am using the following function to calculate the factorial of a number
(53! = 53x52x51x...x1). I have three questions for you (assume I have
practically unlimited available memory):

(a) what is the largest factorial that I can compute using the most
economical datatypes?
(b) does the number in (a) differ if I reframe the computation, say, in
terms of logs?
(c) what is the largest array of 0/1 values that I can declare?

Please help!

Best regards
Loane


Public x As Long
Public facNumber As Integer
Public arrPossibilities() As Byte

[...]

Public Function Factorial(ByVal facNumber As Integer) As Long
If facNumber <= 1 Then
Factorial = 1
Else
Factorial = facNumber * Factorial(facNumber - 1)
End If
End Function 'Factorial




Gary's Student

largest factorial that can be computed
 
You can calculate very large factorials with limited accuracy.

Be careful.

Excel integer math only handles 15 digits. After around 17! you will reach
that limit.
--
Gary's Student


"Loane Sharp" wrote:

Hi there

I am using the following function to calculate the factorial of a number
(53! = 53x52x51x...x1). I have three questions for you (assume I have
practically unlimited available memory):

(a) what is the largest factorial that I can compute using the most
economical datatypes?
(b) does the number in (a) differ if I reframe the computation, say, in
terms of logs?
(c) what is the largest array of 0/1 values that I can declare?

Please help!

Best regards
Loane


Public x As Long
Public facNumber As Integer
Public arrPossibilities() As Byte

[...]

Public Function Factorial(ByVal facNumber As Integer) As Long
If facNumber <= 1 Then
Factorial = 1
Else
Factorial = facNumber * Factorial(facNumber - 1)
End If
End Function 'Factorial





Bill Martin -- (Remove NOSPAM from address)

largest factorial that can be computed
 
Loane Sharp wrote:
Hi there

I am using the following function to calculate the factorial of a number
(53! = 53x52x51x...x1). I have three questions for you (assume I have
practically unlimited available memory):

(a) what is the largest factorial that I can compute using the most
economical datatypes?
(b) does the number in (a) differ if I reframe the computation, say, in
terms of logs?
(c) what is the largest array of 0/1 values that I can declare?

Please help!

Best regards
Loane


Public x As Long
Public facNumber As Integer
Public arrPossibilities() As Byte

[...]

Public Function Factorial(ByVal facNumber As Integer) As Long
If facNumber <= 1 Then
Factorial = 1
Else
Factorial = facNumber * Factorial(facNumber - 1)
End If
End Function 'Factorial

----------------------------------

If you mean by using Excel's built in functions as in your code (multiply for
example) then it only carries a limited number of digits -- 14 or 15. As an
example, start computing your factorials, and check each one by dividing back to
see if you get the previous factorial. When you don't anymore, then you've hit
the limits of Excel's built in functions.

On the other hand if you have a penchant for doing this problem in Excel VBA
which belongs in some other more speedy programming language, you can manually
create your own million+ bit long integer (using arrays of shorter integers) and
write your own multiply and convert to decimal routines, and you can sit around
waiting eons (literally) for execution, then you can compute just about any
factorial you want.

But why would one want to? Time is more of a limitation than anything given
enough programming effort. Given a million years or so you could compute a heck
of a big factorial.

Good luck...

Bill

NickHK

largest factorial that can be computed
 
Does this help ?
http://www.big-numbers.com/

NickHK

"Loane Sharp" wrote in message
...
Hi there

I am using the following function to calculate the factorial of a number
(53! = 53x52x51x...x1). I have three questions for you (assume I have
practically unlimited available memory):

(a) what is the largest factorial that I can compute using the most
economical datatypes?
(b) does the number in (a) differ if I reframe the computation, say, in
terms of logs?
(c) what is the largest array of 0/1 values that I can declare?

Please help!

Best regards
Loane


Public x As Long
Public facNumber As Integer
Public arrPossibilities() As Byte

[...]

Public Function Factorial(ByVal facNumber As Integer) As Long
If facNumber <= 1 Then
Factorial = 1
Else
Factorial = facNumber * Factorial(facNumber - 1)
End If
End Function 'Factorial







All times are GMT +1. The time now is 03:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com