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

In summary, the conversation was about creating a function for calculating the primorial of a given number and generating a list of primes less than or equal to a given number. The steps and functions involved were Range, Prime, and PrimePi, and the final function shown was Primorial[n_]:=Times@@Prime[Range[PrimePi[n]]]. The original question was how to plot these functions together in Mathematica.
  • #1
TylerH
729
0
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:
In[30]:= 
Primorial[2]
Out[30]= Primorial[2]
 
Physics news on Phys.org
  • #2
Primorial is not a built in function. I have never heard of that function either. You will have to define it yourself.
 
  • #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
 
  • #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.)
 
  • #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:
  • #6
Bill Simpson said:
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 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}.

Bill Simpson said:
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.
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:
Primorial[n_]:=Times@@Prime[Range[PrimePi[n]]]
 
Last edited:

1. What is the difference between Plot Primorial[x] and Factorial[x] in Mathematica?

The main difference between Plot Primorial[x] and Factorial[x] in Mathematica is the mathematical function that they represent. Plot Primorial[x] calculates the product of all prime numbers less than or equal to x, while Factorial[x] calculates the product of all positive integers less than or equal to x.

2. How do you use Plot Primorial[x] and Factorial[x] in Mathematica?

To use Plot Primorial[x] and Factorial[x] in Mathematica, you can simply input the desired value of x in the function, such as Plot Primorial[5] or Factorial[10]. This will return the value of the function at that specific point.

3. Can Plot Primorial[x] and Factorial[x] be graphed in Mathematica?

Yes, both Plot Primorial[x] and Factorial[x] can be graphed in Mathematica. You can use the Plot function to graph the values of the function over a range of x values. For example, Plot[Factorial[x], {x, 1, 10}] will graph the factorial function from x=1 to x=10.

4. Are there any limitations to using Plot Primorial[x] and Factorial[x] in Mathematica?

One limitation of using Plot Primorial[x] and Factorial[x] in Mathematica is that the input value of x must be a positive integer. Attempting to use a non-integer value will result in an error. Additionally, the value of x must be within the limits of the data type used by Mathematica, which is approximately 2.5 billion.

5. Can Plot Primorial[x] and Factorial[x] be used in conjunction with other Mathematica functions?

Yes, Plot Primorial[x] and Factorial[x] can be used in conjunction with other Mathematica functions. For example, you can use the Sum function to calculate the sum of the values of Plot Primorial[x] or Factorial[x] over a range of x values. Additionally, you can use the PlotLegends function to label the graphed functions with their respective names.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
246
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
Back
Top