# Questions tagged [primes]

For challenges about identifying and manipulating prime numbers

272 questions
Filter by
Sorted by
Tagged with
275 views

116 views

### Geiger counter prime generation [closed]

This challenge is quite simple to conceptualise, but likely a lot harder to execute. In this challenge, the program will have to detect the number N of its characters that have been randomly changed (...
3k views

### Prime parity peregrination

The purpose of this challenge is to graphically depict a walk on the plane, where the direction of each step $k$ is determined by the primality of $k$ and the parity of its binary expansion. ...
3k views

### ​Cuban​ ​Primes

Given a natural number $n$, return the $n$-th cuban prime. Cuban Primes A cuban prime is a prime number of the form $$p = \frac{x^3-y^3}{x-y}$$ where $y>0$ and $x = 1+y$ or $x = 2+y$ ...
408 views

### Composite Factor Soup

Per the fundamental theorem of arithmetic, for a given number $n$, it is possible to find it's prime factors, and they are unique. Let's imagine we talk only of $n$ that is non-prime (composite). ...
1k views

### Can a neural network recognize primes?

Background Recognizing primality seems like a poor fit for (artificial) neural networks. However, the universal approximation theorem states that neural networks can approximate any continuous ...
6k views

### Return the Closest Prime Number

Challenge This is a simple one: Given a positive integer up to 1,000,000, return the closest prime number. If the number itself is prime, then you should return that number; if there are two primes ...
1k views

### Prime containment numbers (speed edition)

This is sequence A054261 The $n$th prime containment number is the lowest number which contains the first $n$ prime numbers as substrings. For example, the number $235$ is the lowest number ...
2k views

### Prime containment numbers (golf edition)

This is sequence A054261. The $n$th prime containment number is the lowest number which contains the first $n$ prime numbers as substrings. For example, the number $235$ is the lowest number ...
900 views

### Generate some rough numbers

Background A number n can be described as B-rough if all of the prime factors of n strictly ...
3k views

### Is the word coprime?

Given a word, treat every letter as it's number in English alphabet (so a becomes 1, b becomes 2, ...
2k views

### Prime numbers in large number

Given a large number (in base 10), such as 1234567891011121314151617, find prime "subnumbers" in it. A prime "subnumber" is a consecutive sequence of digits (taken from the input), which represents a ...
2k views

### The number of ways a number is a sum of consecutive primes

Given an integer greater than 1, output the number of ways it can be expressed as the sum of one or more consecutive primes. Order of summands doesn't matter. A sum can consist of a single number (...
633 views

### Compute the minimum $a(n)>a(n-1)$ such that $a(1)+a(2)+\dots+a(n)$ is prime (OEIS A051935)

Background Consider the following sequence (A051935 in OEIS): Start with the term $2$. Find the lowest integer $n$ greater than $2$ such that $2+n$ is prime. Find the lowest integer $n'$ ...
378 views

### Goldbach's Comet

Back to back challenges I guess. Hopefully this one is more clear than the last. Background I was playing around with Goldbach's conjecture, and decided to plot evens (on the x-axis) vs the number ...
136 views

### number decomposition [duplicate]

It's been a while since I posted here, so here we go another day another challenge. Challenge : Given a number(n) split it into it's prime factors. Input : A ...
5k views

### Primality testing formula

Your goal is to determine whether a given number n is prime in the fewest bytes. But, your code must be a single Python 2 expression on numbers consisting of only ...
5k views

### Calculate the sum of the first n prime numbers

I'm surprised that this challenge isn't already here, as it's so obvious. (Or I'm surprised I couldn't find it and anybody will mark it as a duplicate.) Task Given a non-negative integer $n$, ...
1k views

### Recover the power from the prime power

It seems that many people would like to have this, so it's now a sequel to this challenge! Definition: a prime power is a natural number that can be expressed in the form pn where p is a prime and n ...
2k views

### Prime Time Travel

Don't tell anyone, but I've nicked my uncle's time travel machine! My uncle is obsessed with prime numbers, though, and that shows in the machine — he has programmed it so that it can only go to dates ...
2k views

### Recover the prime from the prime power

Definition: a prime power is a natural number that can be expressed in the form pn where p is a prime and n is a natural number. Task: Given a prime power pn > 1, return the prime p. Testcases: <...
405 views

### It's getting harder and harder to be composite these days

Given a non-empty list L of integers greater than 1, we define d(L) as the smallest positive integer such that n + d(L) is composite for each n in L. We define the sequence an as: a0 = 2 ai+1 is the ...
2k views

### Is this a consecutive-prime/constant-exponent number?

A while ago, I had a look at the prime factorization of 27000: 27000 = 23 × 33 × 53 There are two special things about that: consecutive-prime: The primes are consecutive: 2 is the ...
2k views

### Prime or highest factor

Challenge: Given an array of non-negative whole numbers numbers in the range of 0 to Infinity, Check whether all of them are primes or not. (You can take input as ...
1k views

### Am I a Pillai prime?

A Pillai prime is a prime number $p$ for which there exists some positive $m$ such that $(m! + 1) \equiv 0 \:(\text{mod } p)$ and $p \not\equiv 1\:(\text{mod }m)$. In other words, an ...
1k views

### Prime Factor Encoding

How the encoding works Given a list of bits: Hold a prime (starting with 2) Have a list For each bit in the input If it's the same as the previous bit, add the ...
2k views

### 1, 2, 3, 14… or is it 15?

A well known song by the Irish rock band U2 starts with the singer Bono saying "1, 2, 3, 14" in Spanish ("uno, dos, tres, catorce"). There are various theories as to the significance of those numbers....
1k views

### Some Lonely Primes

I know, I know, yet another primes challenge... Related A lonely (or isolated) prime is a prime number p such that p-2, ...
138 views

### Find prime factors of sum of non-composite Fibonacci numbers up to n

The Challenge Given a number, find the sum of the non-composite numbers in the Fibonacci sequence up to that number, and find the prime factors of the sum. For example, if you were given 8, the non-...
192 views

tl;dr: Output the values where the reduced prime factorization leader changes. Every positive integer has a unique prime factorization. Let's call the reduced prime factorization just the list of ...
765 views

### Formerly Composite Numbers

Sequence Definition Construct a sequence of positive integers a(n) as follows: a(0) = 4 Each term ...
3k views

### Bertrand's Primes

Bertrand's Postulate states that for every integer n ≥ 1 there is at least one prime p such that n < p ≤ 2n. In order to verify this theorem for n < 4000 ...
710 views

### Cops and Robbers: Redacted Primality (Robbers' Thread)

This is the robbers' thread. The cops' thread is here. Your challenge is to take an uncracked submission from the cops' thread and try to find the original unredacted program. Please comment on the ...
2k views

### Cops and Robbers: Redacted Primality (Cops' Thread)

This challenge was originally sandboxed by Magic Octopus Urn; I adopted and posted it with his permission. This is the cops' thread. The robbers' thread is here. The challenge Step One: Write a ...
1k views

### List all palindromic prime dates between 0000-01-01 and 99999-12-31

You know what a palindrome, a prime and a date are. Your task is to list all dates in 100 thousands of years that fulfill all three characteristics. Nevermind anything but the numbers, use the ...
1k views

### Finding Lonely Primes

Lonely primes (as I call them) are primes, where given a number grid with width w ≥ 3, are primes which do not have any other primes adjacent to them orthogonally ...
1k views

### Minimise the count of prime factors through insertion

Given two positive integers A and B, return the position p that minimises the number of prime factors (counting multiplicities) of the resulting integer, when B is inserted in A at p. For example, ...
1k views

### Prime numbers between n and 2n [duplicate]

Bertrand's postulate states that there is always at least 1 prime number between n and 2n for all n greater than 1. Challenge Your task is to take a positive integer n greater than 1 and find all of ...
2k views

### Factor-poor numbers

If a positive integer $N > 2$ has (strictly) less prime factors (without counting multiplicities) than its successor and its predecessor, we will call it a factor-poor number. In other words, \\$...
2k views

### Is it a Pascal Prime?

It is well known that odd primes will appear in Pascal's triangle exactly twice. However, not all numbers that appear exactly twice in Pascal's triangle are prime. We'll call these numbers Pascal ...
238 views

### Form a list using prime numbers

You have been given N piles of coins. You have decided to divide each of those B1, B2, ..., BN piles among separate groups of people. The amount of people receiving coins has to be a prime number and ...