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 on testing and computing prime numbers.

0
votes
0answers
41 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
369 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
63 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
35 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
68 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
52 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
315 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
56 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
109 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
73 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
196 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
92 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
103 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
63 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
48 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
101 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
96 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
104 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
108 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
94 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
121 views

Efficiently get primes in range

I first had an iterative method, which ran sufficiently fast: ...
4
votes
3answers
583 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
540 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
61 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
100 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
121 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
125 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
169 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
49 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
97 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
146 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
188 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
118 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
217 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
265 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
122 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
995 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
217 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
35 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
625 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
211 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
271 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 ...
3
votes
1answer
165 views

Memory limit hit: optimize code for finding twin primes

I need some help optimizing a Mathematica code so that it'll not max out RAM. Here's the code: Cell 1 ...
1
vote
1answer
70 views

Timing and ListPlot

I am currently trying to examine the Timing function as it relates to generating primes and factorize large integers. What I want to do is to visualize how time ...
0
votes
0answers
66 views

Riemann Zeta function definition was expanded by Euler with an infinite product series [duplicate]

The Euler infinite product series definition for Riemann's zeta function requires that Mathematica use all prime numbers in the product series. Can anyone help me with the code that will give a ...
3
votes
1answer
76 views

A function about prime gaps

I want to define a $f$ function on Mathematica such as this. $f[k]$ gives the smallest $m$ holds $2k=Prime[m+1]-Prime[m]$. For example, $$f[1]=2$$ $$f[2]=4$$ $$f[3]=9$$ $$f[4]=24$$ How can i do that?...
8
votes
4answers
601 views

Goldbach Partition

I want to check the Goldbach conjecture for a big number of $n$, but I don't know how to define this in Mathematica. These are my questions: Find a pair of primes $(p,q)$ for every even integer $n$, ...
9
votes
5answers
653 views

Finding large primes

I'm quite new to Mathematica and I am trying to find large prime numbers that can be written using only the digits 0, 1, 2 and 3 and more than half of these digits have to be 0. For example 1000 and ...