Group Abstract Group Abstract

Message Boards Message Boards

1
|
7.9K Views
|
8 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Function for "Primorials"?

Posted 5 years ago
POSTED BY: Michael Gmirkin
8 Replies
Posted 5 years ago

Hi Michael,

One way to implement primorial.

primorial[n_?Positive] := Product[Prime[i], {i, 1, n}];

primorial[10]
(* 6469693230 *)
POSTED BY: Rohit Namjoshi

Hmm, yeah, that does seem a perhaps slightly more compact way to do it than what I did. :)

Thx!

Would be nifty if they just had a straight function for it, of course...

POSTED BY: Michael Gmirkin

Just for kicks-and-giggles, suppressing a bunch of display output to get a final number:

The Product of the first 10,000 Primes renders a 45,337-digit composite number.

n=100,000: 563,921-digits long.

n=1,000,000: 6,722,809-digits long

n=10,000,000: 77,919,922-digits long (that took a minute to compute!)

n=100,000,000: 885,105,237-digits long. (Heh! That took a while... Almost there)

n=200,000,000: ...we'll have to see how long this takes, assuming it can complete it. ;)

I suspect a 1 billion+ digit Product will fall somewhere between the Products of the first 100mil & 200mil primes. But, what do I know? I just play here. ^_^ (If 200mil primes is over 1bn digits, I can probably narrow it down by halving the difference and halving again 'til narrowed down to exactly how many Primes are needed for the Product to cross the 1bn threshold... Might take a while and a few iterations, tho'...)

EDIT: Well, darn, seems like the Mathematica Kernel craps out after about 20 minutes to 1/2 hour on trying to compute on 200,000,000. Sigh ;)

POSTED BY: Michael Gmirkin
Posted 4 years ago

I have worked this same problem. I see no contact for you, you can reach out at bill.mceachen@gmail.com I have had the same desire for a built-in function

POSTED BY: Bill McEachen
Posted 4 years ago

Hi Bill,

Did you look at the primorial function implementation I provided as an answer? Were you looking for something different?

POSTED BY: Rohit Namjoshi
Posted 4 years ago

I am not looking for anything, just trying to assist Mr Gmirkin up at his higher range. I understand the code completely.

POSTED BY: Bill McEachen

A back-of-the-envelope computation suggests that to get n digits, one requires in the ballpark of LogIntegral[Log[10.]*10^n] primes. For n=10^9, that's around 112,307,000.

Quick check at 10^5. Approximate the count:

In[1002]:= LogIntegral[Log[10.]*10^5]

(* Out[1002]= 20500.5 *)

Check how many digits we get:

In[1004]:= Log[10., Product[Prime[j], {j, 20500}] // N]

(* Out[1004]= 100068. *)
POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard
Be respectful. Review our Community Guidelines to understand your role and responsibilities. Community Terms of Use