Questions tagged [prime-numbers]

Questions on testing and computing prime numbers.

Filter by
Sorted by
Tagged with
0 votes
0 answers
111 views

efficient code to search for formulas for calculating primes

I had an idea for calculating primes using smaller primes given the following: p1=(p2-p3/p4)+(p5-p6/p7) where p1>p5>p2 and p2>p3>p4 and p5>p6>p7 and p1 through p7 are all prime ...
user avatar
  • 445
3 votes
2 answers
221 views

Strange behavior of 'SquareFreeQ'

What is the cause of this strange behavior of SquareFreeQ while PrimePowerQ works correctly: ...
user avatar
  • 2,862
5 votes
8 answers
1k views

Making the number 12345...n

Well, I am trying to write a code that makes the number: $$123456\dots n\tag1$$ So, when $n=10$ we get: $$12345678910$$ And when $n=15$ we get: $$123456789101112131415$$ And when $n=4$ we get: $$1234$$...
user avatar
  • 1,765
0 votes
1 answer
144 views

How to use every number between 2^50 and 2^100 without having to rewrite the code? [closed]

What I have currently written returns a numerical value and stores it in b100. p and q are random integers of size 2^50. I want to use the same code to calculate values where p and q ranges from 2^50 -...
user avatar
  • 31
0 votes
0 answers
71 views

Inverse/Division in finite field?

Think of multiplictavie group of finite field F[p,n], where p is a prime number and n is a positive integer. The whole elements of F[p,n] can be represented as p^n-p^(n-1) positive integers in the ...
user avatar
  • 3,095
4 votes
1 answer
289 views

Largest k such that p^k divides n

(Here all variables are integer.) Is there a built-in function f[n,p] such that f[n,p] = largest k such that p^k divides n For ...
user avatar
  • 3,095
2 votes
0 answers
117 views

Approximate integer factorization

Suppose we would like to compute an approximate prime factorization of a large integer x in the sense that the difference between ...
user avatar
4 votes
1 answer
227 views

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

Definition The Sieve of Eratosthenes is a simple algorithm to find the primes before a given $n$. Starting from $n=2$ you delete all multiples of 2, and keep incrementing till all that are left are ...
user avatar
2 votes
0 answers
66 views

Faster Prime[n] for large n, and for n larger than 10^12

Is there a faster implementation of Prime[] available somewhere, already implemented by someone? (Maybe as a compiled routine?) The default function in Mathematica is slow for large values, and does ...
user avatar
  • 622
2 votes
1 answer
245 views

How to return two values from function

I have a function that generates cipher text for ElGamal encryption and I want to make return two values, but it returns only one. This is the code: ...
user avatar
0 votes
1 answer
100 views

How to prime factorise rational numbers [closed]

I'm aware of the built-in FactorInteger command for finding the prime factorisation of integers. Is there a convenient way of determining the same thing for a rational number, where the prime ...
user avatar
  • 837
0 votes
1 answer
122 views

Factorizing large numbers [closed]

I am trying to factorize large prime numbers with the code bellow. The code works properly for values like 1927 and 69527 (results), but gives no result for larger values like 655051. The code goes as ...
user avatar
5 votes
1 answer
86 views

PrimeQ versus Baillie-PSW primality test [closed]

I read here that Baillie-PSW primality test is proven correct up to $2^{64}$, but I understand PrimeQ is only proven correct up to $10^{16}$, or was that extended ...
user avatar
  • 6,760
1 vote
1 answer
49 views

Chinese remainder theorem large modulo [closed]

I have the following modulo congruences: x ≡ 0 (mod 2) x ≡ 2 (mod 5) x ≡ 21 (mod 41) x ≡ 16793129237622992703097532489897447320171386 (mod 648250901^5) I know, ...
user avatar
0 votes
0 answers
55 views

PowerMod solve for b (exponent)

Using PowerMod[a, b, m] = x I get ...
user avatar
0 votes
1 answer
87 views

One 1 minute (mathematica)

I wanna evaluate how large prime numbers my computer work at most 60 seconds. Of course, I can evalutate this manaully e.g. by trying different values. However, can I do this differently, e.g. by ...
user avatar
5 votes
3 answers
265 views

Speeding up FactorInteger for product of two primes

I have a large integer $N$ of size about 10^150. I know that $N$ is a product of two primes $p$ and $q$. I also know that both $p$ and $q$ are of roughly equal size, so one of them is not, for example,...
user avatar
  • 591
1 vote
2 answers
168 views

Plotting Riemann Prime Counting

I want to program the formula in this page. Didn't take me long to get to my code below. But 1) it only plots the prime counting function and 2) evaluation takes incredibly long. How can I fix it? <...
user avatar
1 vote
0 answers
43 views

Geting all prime numbers from the fibonacci sequence in a range of <1000 [closed]

So my attempt was: PrimePi[Fibonacci[Range[1, 999]]] But that doesnt compile into anything. no result no error. i hope one of you got an idea.
user avatar
  • 29
0 votes
0 answers
145 views

Goldbach's Conjecture?

If we have a list of even integers, how can we find partitions of size 2, then determine if the partitions are composed of prime numbers? So far, I think I would have to use ...
user avatar
1 vote
1 answer
112 views

Find the first 20 primes found by the classical proof of the infinitude of the set of primes

Begin with P={2}; then form,m, the sum of 1 with the product overall elements of P. Place the smallest prime factor of m into P and repeat. Suppose p = {p1,p2,...,pr}, then m = 1+ p1p2p3...pr. Example:...
user avatar
  • 47
2 votes
2 answers
269 views

A Wilson prime is a prime p such that (p−1)!≡−1 mod p^2. Write a procedure which determines all Wilson primes less than10^4

I try to use the for loop to solve this question, but it does not work. And here is what I did. For[p = 2,p<=10000,(p-1)! = -1 mod (p^2),Print[p]] I am not sure ...
user avatar
  • 47
2 votes
1 answer
84 views

How to write this simple task of unimodular prime search in mathematica?

For testing a particular algorithm I found mathematica is the best way as it has all the tools I need. I am stuck in a number theory part and since I am not an expert in mathematica I do not know how ...
user avatar
  • 135
0 votes
0 answers
41 views

Incrementing Numbers

I want to take a prime number p0 = 3, add 2 to it to get a new number p1 = 5, then add four to p1 to get p2, then add 6 to p2 to get p3, etc for a total of 50 times. How do I do that and place my ...
user avatar
1 vote
0 answers
60 views

finding primes using chebyshev bias

Using the problem from my previous question link. For each n, that is n= $10^3$ to $10^6$ with a ten-fold increase, how do I use Chebyshev Bias to display the number of primes (which are in the ...
user avatar
0 votes
1 answer
57 views

How do I find how many numbers are prime(taking absolute value of negatives) in a list? When i use count it returns zero

f = 9x^2 - 78x-10000 list1 = PrimeQ[Abs[f /. x -> {Range[1, 20]}]] Count[list1,True] This is my code. Im trying to find how many prime numbers ...
user avatar
  • 363
2 votes
1 answer
122 views

Trying to create a list that counts the number primes for each remainder class

Considier the remainder of the first $2500$ prime numbers by the numbers from $3$ to $30$, included. Calculate how many primes are in each remainder class. That is, create a list that for each number ...
user avatar
1 vote
1 answer
71 views

A modular version of LinearRecurrence?

I'm playing around with implementing the Lucas probable prime test (mainly so I can understand it better), and would love a version of the LinearRecurrence function that used addition modulo n (with n ...
user avatar
4 votes
0 answers
153 views

Prime factorization over the Eisenstein integers $\mathbb{Z}[\zeta]$

I am trying to write a function f[a_,b_] which takes in two integers $a,b$ and returns the unique factorization of $a+be^{2\pi i/3}$ into the primes belonging to $\...
user avatar
2 votes
1 answer
143 views

Riemann Prime Counting Function correction/pairing terms by Mathematica

Riemann Prime Counting Function: $$f(x)=\operatorname{li}(x)-\sum_\rho\operatorname{li}(x^\rho)-\ln 2+\int_x^\infty \frac{\mathrm dt}{t(t^2-1)\ln t}$$ The second correction/paring terms: $$\sum_\rho\...
user avatar
3 votes
0 answers
80 views

Prime Matrix with determinant of powers $2^x$

Mathematica has commands for finding prime matrices, for example, here is a matrix with randoms in the range $<100$: RandomPrime[100, {3, 3}] This $2 \times 2$ ...
user avatar
  • 2,128
9 votes
2 answers
490 views

Evenly spaced Tick marks for Primes

I'm trying to have the integers evenly spaced on the x axis of a ListPlot, and the prime numbers evenly spaced on the y axis. ...
user avatar
  • 123
0 votes
0 answers
77 views

Numerical comparison of two integrals and a function :

Consider the following integral: $$S(q)=\int_{x=2}^q\sin^2\left(\frac{π\Gamma(x)}{2x}\right)dx$$ And consider the functions : $$R(q)=\frac{q}{\log(q)}$$ $$T(q)=\int_2^q\frac{1}{\log(x)}dx$$ I ...
user avatar
  • 183
8 votes
4 answers
1k views

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

I have to determine how many of the first 50,000 prime numbers (digits) contain the sequence 5, 4, 3, in that order. The numbers don't have to necessarily be consecutive. For example, 566453 is a ...
user avatar
  • 141
1 vote
2 answers
115 views

Generate a sequence of primes giving position and value of a digit in its digit-decomposed version

The prime sequence starts: ...
user avatar
4 votes
1 answer
63 views

Condition for an integer exactly three primes factors? [closed]

I would like to count the number of integers n in the range [1, 10000] that satisfy all three of the properties below: n has ...
user avatar
1 vote
1 answer
79 views

Problem with Solve and PrimeZetaP

I assume this is something to do with limits on numerical precision, but can someone explain the difference in output between these two Solve problems: ...
user avatar
4 votes
1 answer
98 views

Why are there significant differences in efficiency between various instances of ParallelSum?

These four commands ...
user avatar
  • 6,827
0 votes
0 answers
32 views

Variant on `PrimeZetaP`

Mathematica has PrimeZetaP for the prime zeta function $\sum_p \frac{1}{p^s}$ where the sum is taken over all primes. How do I use Mathematica to make an ...
user avatar
3 votes
1 answer
242 views

Solve transcendental equation involving a built-in function [closed]

How can I solve an equation of the following form? $$x = 10+\mathrm{\mathbf{PrimePi}[x]}$$ where $x$ is an integer. I am using Solve but am getting the following ...
user avatar
  • 483
5 votes
0 answers
64 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) ...
user avatar
  • 151
0 votes
0 answers
469 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 ...
user avatar
  • 445
0 votes
1 answer
104 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. ...
user avatar
3 votes
2 answers
215 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 ...
user avatar
3 votes
4 answers
166 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 ...
user avatar
1 vote
1 answer
222 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 ...
user avatar
  • 445
0 votes
0 answers
40 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 . ...
user avatar
-1 votes
1 answer
203 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 ...
user avatar
  • 445
2 votes
1 answer
71 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: ...
user avatar
1 vote
0 answers
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 ...
user avatar
  • 445