Questions tagged [primes]
For challenges about identifying and manipulating prime numbers
347
questions
11
votes
10
answers
2k
views
Smallest prime q such that concatenation (p+q)"q is a prime
Let p, q, and c := (p + q)"q (where " denotes concatenation) be positive integers such that p and c are primes and q is the smallest prime such that c is prime.
Such a prime triple (p, q, (p ...
15
votes
10
answers
1k
views
Sylvester primes
Sylvester's sequence can be defined recursively S(n) = S(n-1)*(S(n-1) + 1) for n >= 1 starting S(0) = 1.
Since S(n) and S(n) + 1 have no common divisors, it follows that S(n) has at least one more ...
13
votes
8
answers
895
views
Lexicographically earliest permutation of the initial segment of nonnegative integers subject to divisibility constraints
The challenge is simple: Reorder the first integers {0, 1, 2, ..., n} into an ordered list so that the following three conditions are met:
If k is the last element in the list, then all of its prime ...
13
votes
12
answers
2k
views
Odds for second smallest prime factor
Given a prime number \$p\$ output the asymptotic density of the set of positive integers which have \$p\$ as their second-smallest distinct prime factor
Input/Output
Input: one of the following ...
10
votes
6
answers
956
views
Unnecessary Fluff
Following the great advice (what do you mean it's not advice?!) on Adding unnecessary fluff we can devise the following task:
Take a list of positive integers and a positive integer \$m\$ as input.
...
8
votes
20
answers
1k
views
Piecing Paired Primes
Problem
You've stumbled upon a paradoxical mathematical phenomenon related to prime numbers. Consider the following scenario:
You have an infinite list of prime numbers: $$2, 3, 5, 7, 11, 13, 17, 19, ....
8
votes
8
answers
407
views
Near miss prime multiples
This challenge was originally posted on codidact.
Given a number \$n \geq 3\$ as input output the smallest number \$k\$ such that the modular residues of \$k\$ by the first \$n\$ primes is exactly \$\...
11
votes
12
answers
1k
views
The all-high powerful numbers
We've had powerful numbers, yes, but what about highly powerful numbers?
Highly powerful numbers
Let \$n\$ be a positive integer in the form
$$n = p_1^{e_{p_1}(n)}p_2^{e_{p_2}(n)}\cdots p_k^{e_{p_k}(n)...
6
votes
19
answers
2k
views
Number of bits needed to represent the product of the first primes
Input
An integer \$n\$ greater than or equal to 1.
Output
The number of bits in the binary representation of the integer that is the product of the first \$n\$ primes.
Example
The product of the first ...
23
votes
31
answers
3k
views
Is this a powerful number?
A powerful number is a positive integer \$n\$ such that for every prime \$p\$ that divides \$n\$, \$p^2\$ also divides \$n\$. Or equivalently, \$n\$ is powerful if and only if it can be written in the ...
-3
votes
7
answers
1k
views
Straight pen strokes for Prime Numbers
Challenge
You are supposed to output the series I recently designed which goes as follows which are pen stroke counts of ascending prime numbers:
...
14
votes
7
answers
1k
views
Gödel encoding - Part II (decoding)
Part I
Previous part was considered encoding of non-empty nested lists with a positive integer.
Reminding the coding procedure \$G(x)\$:
If \$x\$ is a number, \$G(x) = 2^x\$
If \$x\$ is a list \$[n_0,...
31
votes
18
answers
3k
views
Gödel encoding - Part I
Related but different.
Part II
Taken from the book: Marvin Minsky 1967 – Computation:
Finite and Infinite Machines, chapter 14.
Background
As the Gödel proved, it is possible to encode with a unique ...
16
votes
7
answers
2k
views
How Super is this Prime?
A super prime is a prime whose index in the list of primes is also a prime:
...
15
votes
19
answers
2k
views
Sophie Safe primes
Description
Write a program or function that takes in a positive integer \$n\$ as input and outputs all Sophie Germain primes that are safe primes less than or equal to \$n\$. A prime number \$p\$ is ...