Serving the Quantitative Finance Community

  • 1
  • 3
  • 4
  • 5
  • 6
  • 7
  • 9
 
User avatar
Cuchulainn
Posts: 20255
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Large Factorials

February 3rd, 2018, 9:50 am

That's for 10000!

I will try later for 10^6.
Do you have an idea of the running time for 10^6?
 
User avatar
Cuchulainn
Posts: 20255
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Large Factorials

February 3rd, 2018, 9:52 am

(1 240 000)! using .NET multitasking, takes all day. 
Attachments
wallpaper.txt
(6.69 MiB) Downloaded 115 times
 
User avatar
Collector
Topic Author
Posts: 2572
Joined: August 21st, 2001, 12:37 pm
Contact:

Re: Large Factorials

February 3rd, 2018, 11:18 am

Sir a lot of tail zeros in factorial numbers. Is there a known function to know how many tail zeros for a given n! without calculating n! 

0  tail zeros =4 first 4 factorial numbers
1 tail zeros=5 next 5 factorial numbers
2 tail zeros=5 ....
3 tail zeros=5
4 tail zeros=1
5 tail zeros=1
7 tail zeros=1
9 tail zeros=2
12 tail zeros=2
14 tail zeros=1
15 tail zeros=1
17 tail zeros=1
18 = 1
19 =1
21 =1
22 =1
24 =1
26= 1
27 =1
29 = 1
30 =1
32 =1
33 = 1
35=1
37=1
43 =2
45=1
47=1



To find patterns in the dark stop look for patterns and focus on zero patterns ;-)
 
User avatar
ppauper
Posts: 11729
Joined: November 15th, 2001, 1:29 pm

Re: Large Factorials

February 3rd, 2018, 12:18 pm

Sir a lot of tail zeros in factorial numbers. Is there a known function to know how many tail zeros for a given n! without calculating n!
if n is not divisible by 5, then n! has the same number of tail zeros as (n-1)!
if n is divisible by [$]5^m[$] then n! has m more zeros than (n-1)!

it'll be something like
int(n/5)+int(n/[$]5^2[$])+int(n/[$]5^3[$])+....
where int(x) is the largest integer that is smaller than x, eg int(3.8)=3
 
User avatar
Collector
Topic Author
Posts: 2572
Joined: August 21st, 2001, 12:37 pm
Contact:

Re: Large Factorials

February 3rd, 2018, 12:24 pm

Sir a lot of tail zeros in factorial numbers. Is there a known function to know how many tail zeros for a given n! without calculating n!
if n is not divisible by 5, then n! has the same number of tail zeros as (n-1)!
if n is divisible by [$]5^m[$] then n! has m more zeros than (n-1)!

it'll be something like
int(n/5)+int(n/[$]5^2[$])+int(n/[$]5^3[$])+....
where int(x) is the largest integer that is smaller than x, eg int(3.8)=3
nice! good to know when counting large factorial sums, dont want to loose out on a zero!

but is this correct?: "if n is not divisible by 5, then n! has the same number of tail zeros as (n-1)!"

Fact(n=33) has 22 tail zeros. 33 not divisible by 5, and Fact(n=33) has more tail zeros than Fact(n-1=32) 21 tail zeros
 
User avatar
Cuchulainn
Posts: 20255
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Large Factorials

February 3rd, 2018, 1:02 pm

Sir a lot of tail zeros in factorial numbers. Is there a known function to know how many tail zeros for a given n! without calculating n!
if n is not divisible by 5, then n! has the same number of tail zeros as (n-1)!
if n is divisible by [$]5^m[$] then n! has m more zeros than (n-1)!

it'll be something like
int(n/5)+int(n/[$]5^2[$])+int(n/[$]5^3[$])+....
where int(x) is the largest integer that is smaller than x, eg int(3.8)=3
I think it's a good ploy.
https://www.geeksforgeeks.org/count-tra ... al-number/

An interesting related topic is to compute the prime factors of n!.

I have some  C++ code for this; will have a look to see if it works for them C# Biginteger beasts.
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

Re: Large Factorials

February 3rd, 2018, 2:13 pm

Sir a lot of tail zeros in factorial numbers. Is there a known function to know how many tail zeros for a given n! without calculating n!
if n is not divisible by 5, then n! has the same number of tail zeros as (n-1)!
if n is divisible by [$]5^m[$] then n! has m more zeros than (n-1)!

it'll be something like
int(n/5)+int(n/[$]5^2[$])+int(n/[$]5^3[$])+....
where int(x) is the largest integer that is smaller than x, eg int(3.8)=3
nice! good to know when counting large factorial sums, dont want to loose out on a zero!

but is this correct?: "if n is not divisible by 5, then n! has the same number of tail zeros as (n-1)!"

Fact(n=33) has 22 tail zeros. 33 not divisible by 5, and Fact(n=33) has more tail zeros than Fact(n-1=32) 21 tail zeros
Hmmm.. There's something wrong with your factorial, then because x000...000 * y will always have the same number of zeros unless x ends in 5 and y is even or x is even and y is divisible by 5. In the case of factorial, x is always even because there are more factors divisible by 2 than by 5 so that every factor divisible by some number of 5's creates a new product with that many 5's worth of 0's.
 
User avatar
Collector
Topic Author
Posts: 2572
Joined: August 21st, 2001, 12:37 pm
Contact:

Re: Large Factorials

February 3rd, 2018, 3:00 pm

high 5!
 
User avatar
Collector
Topic Author
Posts: 2572
Joined: August 21st, 2001, 12:37 pm
Contact:

Re: Large Factorials

February 3rd, 2018, 4:49 pm

Sir a lot of tail zeros in factorial numbers. Is there a known function to know how many tail zeros for a given n! without calculating n!
if n is not divisible by 5, then n! has the same number of tail zeros as (n-1)!
if n is divisible by [$]5^m[$] then n! has m more zeros than (n-1)!

it'll be something like
int(n/5)+int(n/[$]5^2[$])+int(n/[$]5^3[$])+....
where int(x) is the largest integer that is smaller than x, eg int(3.8)=3
I think it's a good ploy.
https://www.geeksforgeeks.org/count-tra ... al-number/

An interesting related topic is to compute the prime factors of n!.

I have some  C++ code for this; will have a look to see if it works for them C# Biginteger beasts.
Use your prime staff? (primstav (translation: prime staff) is the ancient Norwegian calendar stick. ) 
 
User avatar
ppauper
Posts: 11729
Joined: November 15th, 2001, 1:29 pm

Re: Large Factorials

February 3rd, 2018, 6:29 pm

are we at cross purposes?
from maple,
33!=8683317618811886495518194401280000000
which has 7 trailing zeros
and int(33/5)+int(33/5^2)+int(33/5^3)+.....=6+1+0+0+0+.....=7

32!=263130836933693530167218012160000000
which also has 7 trailing zeros
 
User avatar
Collector
Topic Author
Posts: 2572
Joined: August 21st, 2001, 12:37 pm
Contact:

Re: Large Factorials

February 3rd, 2018, 6:37 pm

are we at cross purposes?
from maple,
33!=8683317618811886495518194401280000000
which has 7 trailing zeros
and int(33/5)+int(33/5^2)+int(33/5^3)+.....=6+1+0+0+0+.....=7

32!=263130836933693530167218012160000000
which also has 7 trailing zeros
yes it was Excel :

32!= 263,130,836,933,694,000,000,000,000,000,000,000 (21 trailing zeros)
33!=8,683,317,618,811,890,000,000,000,000,000,000,000  (22 trailing zeros)

Factorial 32! Excel arbitrage =  469,832,781,987,840,000,000 (that is a nice chunk of even pennies)

would not a warning be in place, we have shaved off the insignificant number of 469,832,781,987,840,000,000 from your factorial!

I got same as you in Mathematica. So Excel is using some very simplified approximation here, when not even getting a small factorial like n=32 correct. This was on the new excel Mac version  15.41 (that should be equal to the PC version, at least less Mac like than before). I though Excel was fine with such small Factorials, wrong again. And I need to Factor in that!

Someone should build a proper spreadsheet.. with a super fast built in computer language, and also math functions similar to Mathematica or Maple.

Looks like Excel starts to loosing out already at 21!   (may be a hint of an age limit before starting with high octane factorials?)
Last edited by Collector on February 3rd, 2018, 7:22 pm, edited 2 times in total.
 
User avatar
FaridMoussaoui
Posts: 327
Joined: June 20th, 2008, 10:05 am
Location: Genève, Genf, Ginevra, Geneva

Re: Large Factorials

February 3rd, 2018, 7:21 pm

A good estimate of the number of leading zero is something like:

\frac{9}{10} \sum_{k = 1}^{\infty} \floor{\frac{n}{5^k}} + \frac{1}{10} n log_{10} n - \frac{n}{10 log 10}
 
User avatar
FaridMoussaoui
Posts: 327
Joined: June 20th, 2008, 10:05 am
Location: Genève, Genf, Ginevra, Geneva

Re: Large Factorials

February 3rd, 2018, 7:21 pm

oops, no latex formulas working?
 
User avatar
Collector
Topic Author
Posts: 2572
Joined: August 21st, 2001, 12:37 pm
Contact:

Re: Large Factorials

February 3rd, 2018, 7:25 pm

oops, no latex formulas working?
you must use \ ( \ )
\(\frac{9}{10} \sum_{k = 1}^{\infty} \floor{\frac{n}{5^k}} + \frac{1}{10} n log_{10} n - \frac{n}{10 log 10}\)
Last edited by Collector on February 3rd, 2018, 7:26 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20255
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

Re: Large Factorials

February 3rd, 2018, 7:26 pm


if n is not divisible by 5, then n! has the same number of tail zeros as (n-1)!
if n is divisible by [$]5^m[$] then n! has m more zeros than (n-1)!

it'll be something like
int(n/5)+int(n/[$]5^2[$])+int(n/[$]5^3[$])+....
where int(x) is the largest integer that is smaller than x, eg int(3.8)=3
I think it's a good ploy.
https://www.geeksforgeeks.org/count-tra ... al-number/

An interesting related topic is to compute the prime factors of n!.

I have some  C++ code for this; will have a look to see if it works for them C# Biginteger beasts.
Use your prime staff? (primstav (translation: prime staff) is the ancient Norwegian calendar stick. ) 
Image