19 votes
Accepted

How to calculate $\prod\limits_{p}\frac{p^2+1}{p^2-1}$?

A Trace reveals the problem: ...
Michael E2's user avatar
  • 234k
15 votes

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

If you need all the primes that are twin primes up to n then. ...
rhermans's user avatar
  • 36.3k
14 votes

Accuracy of PrimeQ function

Turning my comment into an answer, One of the tests performed by PrimeQ for machine-sized integers, namely Miller-Rabin using up to the first 12 primes as bases (...
ilian's user avatar
  • 25.5k
14 votes
Accepted

Evenly spaced Tick marks for Primes

As people on the comments pointed out this may be a problematic in various ways, but if all y-values of your points are primes, this can be accomplished with ...
kirma's user avatar
  • 19k
14 votes
Accepted

Making the number 12345...n

FromDigits@Flatten[IntegerDigits /@ Range[15]] 123456789101112131415 A function to do it: ...
murray's user avatar
  • 11.8k
13 votes

Determining occurrence of a sequence of numbers in the first 50,000 primes

out = Select[MatchQ[IntegerDigits[#], {___, 5, ___, 4, ___, 3, ___}] &]@ Prime[Range[50000]]; Length@out 1588 ...
kglr's user avatar
  • 392k
12 votes
Accepted

Goldbach Partition

Take a look at IntegerPartitions, although it relies on brute-force enumeration that is unlikely to scale well. ...
Mr.Wizard's user avatar
  • 271k
11 votes

Some information about PrimeQ function

Source: https://reference.wolfram.com/language/tutorial/SomeNotesOnInternalImplementation.html PrimeQ first tests for divisibility using small primes, then uses the Miller–Rabin strong ...
Julien Kluge's user avatar
  • 5,335
11 votes

Determining occurrence of a sequence of numbers in the first 50,000 primes

Prime and IntegerDigits are Listable, ___ (i.e. ...
Artes's user avatar
  • 57.2k
11 votes
Accepted

Writing a number 'm' as a sum of 'n' prime numbers

Clear["Global`*"] primePartitions[m_Integer?Positive, n_Integer?Positive] := IntegerPartitions[m, {n}, Prime /@ Range[PrimePi[m]]] For sum of exactly ...
Bob Hanlon's user avatar
  • 155k
11 votes

What is a good way to compute successive primorials with Mathematica?

Mathematica code is already provided in the The On-Line Encyclopedia of Integer Sequences, here http://oeis.org/A002110 oeis Sol 1 ...
rhermans's user avatar
  • 36.3k
10 votes
Accepted

Computing the twin prime constant with Mathematica

The problem with your code is that N[Product[...]] calls NProduct[...] which turns integers into reals before ...
SonerAlbayrak's user avatar
10 votes
Accepted

Checking whether a certain number is prime

You are right!! Reverse /@ Table[IntegerDigits[Prime[i]], {i, 549, 2, -1}] // Flatten // FromDigits // PrimeQ True ...
OkkesDulgerci's user avatar
10 votes
Accepted

Largest k such that p^k divides n

IntegerExponent IntegerExponent[120, #] & /@ {2, 3, 5, 7} (* {3, 1, 1, 0} *)
Greg Hurst's user avatar
  • 35.8k
10 votes

Making the number 12345...n

f1 = FromDigits @ StringRiffle[Range[#], ""] &; f1 /@ {4, 10, 15} {1234, 12345678910, 123456789101112131415} ...
kglr's user avatar
  • 392k
9 votes

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

General There are as many solutions as prime numbers If you Solve for $x$ Solve[32 x + 1 == p, x] ...
rhermans's user avatar
  • 36.3k
9 votes

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

One convention (the usual?) for counting twin primes is to count just 1 for each pair. The original question is ambiguous, but it seems that @rhermans (+1) has a different convention of counting 2 for ...
KennyColnago's user avatar
  • 15.2k
9 votes
Accepted

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

Here's a very short version: primePairs[x_] := With[{primes = Prime[Range[PrimePi[x]]]}, Intersection[primes, primes - 2]] It's returns the same numbers as @...
Niki Estner's user avatar
  • 36.1k
9 votes

Can I use NextPrime[n] up to n=10^14?

NextPrime has no problems evaluating for large numbers well above $10^{14}$. I think it's safe to assume these are real prime numbers, for confirmation see the ...
rhermans's user avatar
  • 36.3k
9 votes

Make a list of the first 100 primes, keeping only ones whose last digit is less than 3

SolveValues[x <= Prime[100] && Mod[x, 10] < 3, x, Primes] ...
kglr's user avatar
  • 392k
8 votes

Goldbach Partition

I propose to use FrobeniusSolve. It seems it gives results fairly quickly. How large is the number $n$ ? ...
Anton Antonov's user avatar
8 votes

Manipulate Slider to take its values from primes

Here is the example from TrackingFunction: ...
Michael E2's user avatar
  • 234k
8 votes

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

I'll comment on why your initial attempts failed and attempt to correct them. Others have done a better job suggesting better approaches. ...
jjc385's user avatar
  • 3,473
8 votes
Accepted

Solve transcendental equation involving a built-in function

Solve[{0 < x < 1000 && x == 10 + PrimePi[x]}, x, Integers] (* {{x -> 16}, {x -> 17}} *)
Akku14's user avatar
  • 17.3k
8 votes

Determining occurrence of a sequence of numbers in the first 50,000 primes

This should be speedier... Pick[p = Prime@Range@5*^4, StringMatchQ[IntegerString[p], "*5*4*3*"]]
ciao's user avatar
  • 25.7k
8 votes
Accepted

How to make a graphic for Sieve of Eratosthenes with a legend

ClearAll[primes] primes[n_] := Prime[Range @ PrimePi[n]] n = 120; array = Partition[Range @ n, 10]; split = Split[primes[n], #^2 >= n &]; ...
kglr's user avatar
  • 392k
8 votes

Making the number 12345...n

Without using IntegerDigits or string processing: ...
flinty's user avatar
  • 24.7k
8 votes

Can I use NextPrime[n] up to n=10^14?

The prime generator and the primality proving package both seem very quick at $10^{14}$: ...
Roman's user avatar
  • 46.9k
8 votes
Accepted

Make a plot of the nth prime divided by n*log(n) ,for n from 2to1000

DiscretePlot[Prime[n]/(n Log[n]), {n, 1000}]
Roman's user avatar
  • 46.9k
8 votes
Accepted

Use of PrimeQ in Solve

PrimeQ is a predicate that only ever evaluates to True or False. It does not indicate that $...
MarcoB's user avatar
  • 66.6k

Only top scored, non community-wiki answers of a minimum length are eligible