# Questions tagged [prime-numbers]

Questions on testing and computing prime numbers.

127 questions
Filter by
Sorted by
Tagged with
57 views

### parallelizing inner For loop of code [closed]

I modified the code here: Integer sequence and RAM limits To decrease the RAM usage, for generating more terms, the main limiting factor now is CPU speed. Is it possible to modify the code to be ...
56 views

### How does Mathematica implement PrimePi?

I'm attempting to implement a "PrimePi" function from scratch. I have a highly optimized Sieve implemented, and I've read a handful of papers to get a rough idea how to implement the Meissel & ...
55 views

### How Prime[n] is implemented and why is that bounded? [duplicate]

How is Prime[n] implemented in Mathematica? I have just observed that calculating large primes is quite fast (but not in O(1) ...
60 views

### Identifying repeating patterns in a list of numbers

I have some generated lists of natural numbers which have a small number of distinct values, ie. referencing the variable "rowToCheck" for each list: list1: rowToCheck = 3: length=7, distinctvalues=3 ...
58 views

### Find the position of all the prime numbers up to a given number

I want Mathematica code the does what the following pseudocode does. ...
129 views

### Efficient way to list zeroes of an oscillating function

From "The First 50 Million Prime Numbers" by Don Zagier: primes are integral roots of$$1-\frac{\sin(\frac{\pi\Gamma(s)}s)}{\sin(\frac\pi s)}.$$ The graph of this function looks like I would like to ...
149 views

### The difference of Prime in Solve doesn't work

Can someone explain why Solve does not work with Prime difference? This cond does not work: Solve[Prime[n] - Prime[m] == 8, {n, m}, Integers] But you can find ...
191 views

### Finding recurrence formulas from procedural code and output lists associated with integer sequences

This code outputs 37 sequences and takes about 15-minutes to run. I would like to be able to see how many and which variables { i, j, k, m, n } each of the 37 ...
36 views

### First 3 unknown status for $R(n)$

Let R(1) = $1 - 1$ R(2) = $(1\times11) - (1+11)$ R(3) = $(1\times11\times111) - (1+11+111)$ R(4) = $(1\times11\times111\times1111) - (1+11+111+1111)$ R(4) is the only prime known with such form . ...
176 views

### automatic formula finding function [duplicate]

I am curious how easy it would be to automatically find some formulas related to basic number theory OEIS sequences using some Mathematica search algorithm for a small set of OEIS sequences as a ...
46 views

### Prime factorization related functions: prime factor to its power and power of prime [duplicate]

FactorInteger can be used to perform prime factorization: FactorInteger[5^2 7^3 11^4] Results in: ...
116 views

### Integer sequence and RAM limits [closed]

I am trying to calculate the set of unique differences in a sequence, however the sequence grows fast and I hit the RAM limit of my PC for nthPrimeToUse = 11. For nthPrimeToUse 1 to 10 the output of ...
49 views

### Code PrimePi (writing out the function)

I would like to write a function that outputs the built in function PrimePi, which gives the number of primes π(x) less than or equal to x. So far, I have: ...
248 views

### The sum of digits of Mersenne primes

I have problem to calculate the sum of digits of the mersenne primes $M_{57885161}$ , $M_{74207281}$ , and $M_{77232917}$. I'm not a 'computer guy', but I know that the sum of digits of $M_{82589933}$ ...
131 views

### Displaying the number of repeating digits in a fraction

I would like to check how many repeating digits are in a large fraction, I manually did it for the first few, but the repeating length is too large to manually check. ...
81 views

### What is wrong with my procedural function to find all prime $\leq x$? [closed]

I want to create a simple function that prints all prime numbers from 1 to x. I have the following code, which doesn't cause any errors from the kernel but it doesn't return anything: ...
35 views

### How can I get an array of very large primes when I don't have a lot of memory?

I would like to perform computations on an array of primes within the range $[2,10^{15}]$. For the moment, I am selecting such an array using the command: ...
858 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 ...
111 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 ...
153 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 ...
204 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 ...
61 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 ...
422 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: ...
81 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 ...
85 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): ...
59 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 ...
473 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?
67 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? ...
142 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 ...
2k 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 ...
94 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 ...
238 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: ...
118 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 ...
139 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 ...
92 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 ...
54 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: ...
157 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 ...
135 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 ...
141 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 ...
162 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 ...
132 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 ...
149 views

### Efficiently get primes in range

I first had an iterative method, which ran sufficiently fast: ...
657 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: ...
804 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 ...
78 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: ...
70 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.
128 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 ...
140 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(...
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 ...