Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Plot Primorial[x] and Factorial[x] in Mathematica

  1. Aug 7, 2011 #1
    How do I plot those together?

    It seems like Mathematica isn't recognizing Primorial. Every time I try to use it, it just prints it back for output.

    For example:
    Code (Text):
    Out[30]= Primorial[2]
  2. jcsd
  3. Aug 7, 2011 #2


    Staff: Mentor

    Primorial is not a built in function. I have never heard of that function either. You will have to define it yourself.
  4. Aug 7, 2011 #3
    Definition of Primorial http://oeis.org/A002110

    In[1]:= Primorial[n_]:=Times@@Prime[Range[n]]

    In[2]:= Primorial[1]
    Out[2]= 2

    In[3]:= Primorial[4]
    Out[3]= 210
  5. Aug 8, 2011 #4
    Okay, I see Times@@ can be used to multiply all the members of a list. How could I generate a list of all primes less than or equal to n? (I'm interested in the other primorial. n# := the product of all p such that p is prime and p <= n.)
  6. Aug 8, 2011 #5
    If you are a beginner with Mathematica then you need to take the replies posted here apart, use the help system or Google to read the documentation for each function, see what each part does and how they work. Then you begin putting the pieces back together, one step at a time, until you see how the whole thing works.

    What does Range[] do? Then what does Range[4] do?
    What does Prime[] do? Then what does Prime[2] do?
    What does Prime[{2,5}] do? What does Prime[Range[4]] do?
    Finally how does all this come together in what I showed
    and how does that relate to the original question?

    I'm confused by your "I'm interested in the other primorial."
    Is that different than what I showed? How?

    Perhaps I misunderstood and made a mistake. If so then please explain what I missed.
    Last edited: Aug 8, 2011
  7. Aug 8, 2011 #6
    I have prior programming experience, I've already deduced what they do. Range[n] = {1,...,n}, Prime[n] = nth prime, Prime[{2,5}] = 2nd and 5th prime = {3, 11}.

    The other primorial is the product of all primes less than or equal to n. For example, Primorial[5]=Times@@{2,3,5}.

    What I don't know how to do is create a list of all primes less than or equal to a given n.

    EDIT: OH YEAH!!! I forgot about the prime counting function, which, research says, is called PrimePi[] in Mathematica. So,
    Code (Text):
    Last edited: Aug 8, 2011
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook