# Questions tagged [prime-numbers]

Questions on testing and computing prime numbers.

188 questions
Filter by
Sorted by
Tagged with
44 views

### When and how CoprimeQ[a, b, c] is evaluated for generic a, b, c? [closed]

Most Mathematica functions return input sentence unevaluated, when there is no simple solution, or, the answer cannot be determined from the input data. For example, ...
• 1,495
62 views

### How does the Prime function work?

This is somewhat interesting. I was trying to do a demo to abort a hopeless computation, so I decided to ask Mathematica for the ten trillionth prime. To be honest, I just typed ...
114 views

### All composite numbers are crossed by the lines

I'm trying a version of the code with the concavity of the parabola upwards (y=x^2), but I'm not succeeding. I appreciate any help. ...
62 views

### Optimizing getting a large number of values from PrimePi

I found out yesterday that there is a conjecture that the following function generates an addition chain: $f(n)=\pi({n(n+1)\over 2}+1)$ for and integer $n\ge 1$. $\pi(x)$ is the prime counting ...
• 163
1 vote
54 views

• 2,021
148 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 -...
• 31
138 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 ...
• 4,315
356 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 ...
• 4,315
157 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 ...
• 487
723 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 ...
93 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 ...
• 632
922 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: ...
173 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 ...
• 1,043
135 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 ...
118 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 ...
• 7,134
1 vote
102 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, ...
91 views

### PowerMod solve for b (exponent)

Using PowerMod[a, b, m] = x I get ...
100 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 ...
306 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,...
• 601
1 vote
287 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? <...
1 vote
72 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.
• 29
179 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 ...
1 vote
159 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:...
• 47
353 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 ...
• 47
88 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 ...
• 145
136 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 ...
1 vote
63 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 ...
1 vote
98 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 ...
• 373
240 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 ...
1 vote
### 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 \$\...