Questions tagged [primes]
For challenges about identifying and manipulating prime numbers
352 questions
2
votes
13
answers
675
views
List of prime distances
Task:
Write a code golf program that, given two positive integers n and m, returns a list of the distances between consecutive prime numbers in the range [n, m] ...
13
votes
18
answers
2k
views
Is it a product of 4 unique primes (A046386)?
A046386 is the sequence of all natural numbers that are the product of exactly 4 distinct primes.
Write the shortest program, function, or code snippet, that, when given a natural number, outputs ...
4
votes
4
answers
580
views
Find the boolean logic to check if a number is prime!
Your task is to find a boolean expression that uses AND (\$\land\$), OR (\$\lor\$), XOR (\$\oplus\$), and NOT (\$\lnot\$) operators and binary digit positions (\$d_1,d_2,d_3,d_4,d_5,d_6,d_7,d_8,d_9,d_{...
8
votes
18
answers
4k
views
Is this number Ugly?
Related, but not dupe (Asking about the n-th k-smooth number whereas I'm only asking if a certain number is 5-smooth.)Source: Partially inspired by Leetcode's 5-smooth Number problem, but partially ...
17
votes
10
answers
2k
views
The smallest number with a given water capacity
This is the outline of this challenge: Every number greater than or equal to two has a prime factorization. A prime factorization can be represented as a bar graph. Every bar graph has a water ...
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
1k
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
1k
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.
...
9
votes
21
answers
2k
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
479
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 ...