Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [prime-numbers]

Questions on testing and computing prime numbers.

2
votes
2answers
767 views

Checking whether a certain number is prime

Using the primality test on this site, I found that the concatenation of the digit reversal of the first 548 odd primes in the reverse order is a prime!. It is only a 1998-digit prime, but it took ...
0
votes
1answer
43 views

Counting Ramanujan Primes

The Ramanujan primes can be easily plotted with the following code ...
0
votes
0answers
81 views

On the distribution of PIPs and Ramanuajn primes in Ulam's spiral

The Ulam's spiral represents the prime numbers by spiral. The code provided by Wolfram Mathematica is easy and given by ...
1
vote
1answer
42 views

Inverting the order of a Table - Prime numbers

In a previous post I asked for the possibility to have a binary image of the coprimality inside the natural numbers. The following code ...
-1
votes
1answer
88 views

Plot Ramanujan Primes

I often investigate on Ramanujan primes. Is it possible to apply this procedure described in DotPlot for prime numbers ? I think so but which is the condition I should use? I am trying from several ...
2
votes
1answer
118 views

DotPlot for prime numbers

I was thinking to use a dotplot to give a description of prime numbers. On Wolfram website there is written that each dotplot can be built by ...
0
votes
0answers
42 views

magic square with prime numbers of any order

how could you create a script in Mathematica that generates magic squares of order n, but that the numbers that form the square are all primes I've looked at what's in other answers but I can not ...
6
votes
2answers
383 views

Computing the twin prime constant with Mathematica

The twin prime constant is defined as $$ C _2 = { \prod \limits_{p \geqslant 3 }} \, \frac{p(p-2)}{(p-1)^2}. $$ Translating this directly in Mathematica code gives: ...
0
votes
2answers
67 views

Function that returns prime numbers contained between n and 2n - Chebyshev's inequality

Write a function f[n] that returns prime numbers contained between n and 2n. It's a ...
0
votes
0answers
36 views

Odd glitch in `PrimePi` [duplicate]

When I plot PrimePi, I get an odd graphical glitch for some values of x. For example, this plots fine: ...
1
vote
2answers
72 views

Asymptotic density of twin primes gives wrong result in Mathematica [closed]

One can compute the amount of twin primes below a positive integer $n$ by using the Mathematica command (taken from OEIS A001097): ...
1
vote
1answer
54 views

How can I compute how many primes of this kind are up to $N$?

In the following link: https://oeis.org/A079796/b079796.txt we can see the first 10,000 prime numbers $p$ with the property that both $(3p)^2 + p^2 + 3^2$ and $(3p)^2 - p^2 - 3^2$ are primes ...
8
votes
5answers
338 views

Does Mathematica have a twin prime equivalent of `PrimePi`?

Well, it's all there in the title! I'd like to be able to plot the number of twin primes =<x. Is there an inbuilt function that can do this?
2
votes
1answer
59 views

Showing the difference between Primes

I create a list of primes in table form... How do I generate and display the difference between the prime numbers in sequence? ...
2
votes
1answer
115 views

Is a probabilistic primality test implemented in Mathematica?

Imagine that I need to verify that a specific integer, like $n = 10^{1347}+3049$ is prime. ProvablePrimeQ takes a lot of time, and, even if it will eventually work ...
4
votes
4answers
1k views

How to ask WolframAlpha to find 'x such that p=32*x+1 is prime'

I want to find prime $p$ in form of $p=32 x+1$ How can I ask WolframAlpha for such $x$ that will fulfil this equation? EDIT: let's say that $100$ or $n$ solutions is enough for me EDIT2: I need x's ...
0
votes
2answers
75 views

Making Prime number

i know there is a Command in Matematica to get prime number, but i want to break down the code,here is what i got ...
5
votes
5answers
203 views

Question about how to speed up Mathematica code

When looking at the Minimal Goldbach prime partition point {p,q} for each n; where n=10^i and i = 2,3,4,...,10; I notice that these points reside in an interval with center n/2 and radius 250: ...
0
votes
1answer
97 views

Generate a prime number satisfying a condition

Building on the same context of this question Is it possible to enforce constraints on the properties of the generated prime? For example, I'm trying to find a prime $p$ in the range specified in the ...
2
votes
1answer
110 views

Generate a prime number in a range with fixed $n$ most significant bits

I'm new to Mathematica so my question might be trivial. How do I generate a $200-bit$ prime with the condition that the 10 most significant bits in its binary representation are equal to some binary ...
2
votes
2answers
67 views

Product over several previous primes

I'd like to evaluate $$\prod_p\left(1-\frac1p\right)$$ over the $k$ largest previous primes $p\le n/2$, where $n$ is the parameter. E.g., if $n=20$ and $k=3$, I'd like the product to be over the 3 ...
0
votes
0answers
49 views

Question about how to use NestWhileList

I start with: n = 2228; m = n/2; PreviousPrime[n_] := NextPrime[n, -1] I use NestList to build the following list: ...
1
vote
1answer
112 views

Number of primes between two integers x and y (with x < y and excluding x and y)

There is a formula given at the bottom of the following webpage: https://math.stackexchange.com/questions/288747/how-to-find-number-of-prime-numbers-between-two-integers to calculate the number of ...
0
votes
3answers
99 views

Listing products of prime powers

Given a positive integer $n$, what is the code to list $2^{a_2}3^{a_3}\cdots p^{a_p}$, where $a_i\ge 0$ are integers, with respect to the lexicographic ordering on $(a_2,a_3,\ldots, a_p)$? The only ...
1
vote
1answer
107 views

Summing over Prime Factors (without repetition)

Wolfram Mathworld (http://mathworld.wolfram.com/SumofPrimeFactors.html) describes a function sopfr(n), the sum of prime factors, which I currently need. This code doesn't work when I insert it in ...
4
votes
2answers
113 views

Sum indexed by Primes [duplicate]

How can I express a sum indexed by primes in Mathematica? Two examples that I am interested in are (1) where the primes go from $p=2$ to, say, $p=17$. (2) It would also be useful to have the sum ...
1
vote
0answers
98 views

How can I speed up Mathematica calculations? [closed]

I am using Mathematica 11.1 to deterministically test the primality of a set of very large numbers (i.e. more than 1000 digits). Some of these calculations (understandably) take a lot of time (several ...
0
votes
2answers
126 views

Efficiently get primes in range

I first had an iterative method, which ran sufficiently fast: ...
4
votes
3answers
600 views

How to generate primes of the form 8n+1?

I'm trying to extract from the list of the first one hundred primes those which have the form 8n+1. I have tried using Select but this just gives me an empty list: ...
2
votes
1answer
577 views

List of Coprimes

Is there a way to generate a list of parametrized length, say $L$, of integers which are relatively prime among them? I would like to take into account their word-length as well, so for example the ...
2
votes
0answers
65 views

Replacing all primes with 0 [closed]

I am attempting to utilise the Condition function to replace all primes in the list by a 0. Here are my codes: ...
1
vote
1answer
54 views

How to make substitution using parallel ranges? [closed]

Example : $$y=x^2+x+1,$$ where 1st range: $x=$ 1 to 1,000,000; 2nd range: $x=$ 1,000,001 to 2,000,000; 3rd range: $x=$ 2,000,001 to 3,000,000.
0
votes
2answers
104 views

Receiving no output when executing this code

Today I was trying to compute the value of a function in one point ($f(3594641)$) using Mathematica. The main difficulty it has is that it requires both calculating primorials (product of primes) and ...
3
votes
1answer
123 views

Exact formula for the $n$ th prime

There is an exact $n$th prime number formula from mathworld A double sum for the nth prime pn is $$p_n=1+\sum_{k=1}^{2(\lfloor n\ln n\rfloor+1)}\Biggl[1-\Biggl\lfloor\frac{\sum_{j=2}^k 1+\lfloor s(...
0
votes
1answer
129 views

How to plot the number of Mersenne Primes lower than a given input?

I would like to plot the number of Mersenne primes (primes of the form $2^n-1$) lower than a given input. I am totally noob to mathematica and I do not know where to start from. I have tried to ...
0
votes
1answer
193 views

Some information about PrimeQ function

In Mathematica there is a built-in function called PrimeQ which tests given input as True or ...
1
vote
1answer
50 views

How can I know the number of solutions of an equation involving prime numbers?

I have to admit that I am totally noob to mathematica, and I have a question for which I have not found any easy-to-understand answer about. How could I calculate the number of prime numbers of a ...
0
votes
1answer
99 views

I need some help with this algorithm

I'm quite new to Mathematica yet, so there's probably a lot of not-so-subtle problems (indeed the algorithm isn't even running yet). My goal with this algorithm is to input an integer $n$ and get all ...
0
votes
2answers
150 views

Powers of prime factors of a positive integer $n$ in “Mathematica”?

I would like to find the powers of a prime in the unique prime factorization of an $n$. I want a function $f[n,p]$ such that $n,p$ are given and I need to know what the power of $p$ is. For instance ...
5
votes
3answers
191 views

Manipulate Slider to take its values from primes

How do I make the slider values in Manipulate be values that are prime numbers? Many thanks for any assistance. Firstly, many thanks for all your considered and rapid responses. It really is very ...
1
vote
1answer
121 views

Generating a very large list of integers not divisible by a set of primes

I have read (58520), but the solutions there do not work when using a large maximum value because they rely on Range. For example, ...
3
votes
3answers
219 views

OEIS A144311 Generating function

I'm looking for a way to use calculate OEIS A144311 efficiently in Mathematica. First, let's define the series. In one sense or another, this series considers the number between "relative" twin ...
12
votes
1answer
271 views

Accuracy of PrimeQ function

Using PrimeQ in Mathematica 10 on integers up to $2\cdot 10^{5717}$ the function appears to work. The Documentation for Mathematica 5 says that ...
2
votes
1answer
124 views

Twin Prime Max Gaps (Performance Tuning)

Ok, let's build a foundation here: A common way of testing primality, is dividing by all primes smaller than the number's square root. For instance, $97$ is prime because dividing by none of the ...
-1
votes
1answer
1k views

Generate list of first 100 prime number? [closed]

I know how to generate a list of prime numbers up to a limit, but how would I generate the first 100 prime numbers in a list?
2
votes
2answers
220 views

Brute force evidence of possible proof of twin prime conjecture

Trying to avoid shelling out hundreds of dollars so I'm using what I can for free online. This is what I've come up with so far: https://dl.dropboxusercontent.com/u/76769933/TwinPrimes%203Podd.cdf ...
3
votes
1answer
37 views

What is the form of a PrimalityProving`PrimeQCertificate?

I understand the format of a proof of compositeness of an integer produced by PrimeQCertificate: it's well-documented that ...
3
votes
1answer
683 views

Plot prime numbers in spiral form, in the clockwise direction

I want to plot first 100 Prime numbers in circular format (on circular orbit) in Mathematica. How can i do this?
5
votes
0answers
222 views

The inverse function of “Prime” [duplicate]

Consider p such that PrimeQ[p] == True. How do I compute n such that Prime[n] == p? In other words, what is the inverse ...
10
votes
2answers
274 views

Primes Race (Mathematica Efficiency)

I am currently working with a paper that deals with this concept of Prime Races. You essentially create a large list of prime numbers and then split that list into two teams. You are assigned to ...