Questions tagged [primes]

For challenges about identifying and manipulating prime numbers

298 questions
Filter by
Sorted by
Tagged with
1k views

Make it prime with the smallest suffix

Given a positive integer as input, output the smallest positive integer such that appending its digits (in base 10) to the end of the input number will form a prime number. Examples ...
1k views

Calculate Home Primes

The Home Prime of an integer $n$ is the value obtained by repeatedly factoring and concatenating $n$'s prime factors (in ascending order, including repeats) until reaching a fixed point (a prime). ...
876 views

Random pair of primes

Given a positive input $n$, output a random pair of primes whose difference is $n$. It's fine if there's another prime between them. Every pair should possibly appear and the program should have ...
667 views

Finding Distant Primes

Let us call a prime $p$ an $(m,k)$-distant prime $(m \ge 0, k \ge 1, m,k \in\mathbb{Z})$ if there exists a power of $k$, say $k^x (x \ge 0, x \in\mathbb{Z})$, such that $|k^x-p| = m.$ For ...
1k views

I ain't no Fortunate sum

The primorial $p_n\#$ is the product of the first $n$ primes. The sequence begins $2, 6, 30, 210, 2310$. A Fortunate number, $F_n$, is the smallest integer $m > 1$ such that $p_n\# + m$ ...
2k views

Reconstruct an integer from its prime exponents

All integers $n > 0$ can be expressed in the form $$n = \prod_{\text{prime } p} p^e = 2^{e_2} 3^{e_3} 5^{e_5} 7^{e_7} \cdots$$ This form is also known as it's prime factorisation or prime ...
141 views

Python Prime Problem [duplicate]

Your challenge is to write a Python program to print all the primes (separated by whitespace) less than a given integer N with an asterisk (...
4k views

Ginormous number

Output this 1364-digit base-10 number: ...
833 views

Prime generating function

Background The Python code ((((((((n%35)^11)*195)|53)&181)+n)%168)*n)+83 produces 74 distinct primes for $0 \le n \le 73$. This code also works in Java. The ...
1k views

All-inclusive semi-primes

$723 = 3 \times 241$ is a semi-prime (the product of two primes) whose prime factors include all digits from $1$ to $n$, where $n$ is the total number of digits between them. Another way to ...
3k views

Looks prime to me!

Figuring out whether a given number is prime, while not very complicated, is kind of hard. But making a guess doesn't need to be. Seeing whether a number is a multiple of 2 or 5 is easy - you can just ...
3k views

Shortest “arithmetic” formula to output 1000 primes

Write a formula using only the digits 0-9, +, *, -, <...
2k views

Delicate primes

Inspired by Find the largest fragile prime. By removing at least 1 digit from a positive integer, we can get a different non-negative integer. Note that this is different to the ...
1k views

Double Prime Words

Consider a word/string of length $n$, only including the letters A-Z, a-z. A word/string is a double prime word if and only if n is prime and the sum of the letters, s, is also prime, using their ...
2k views

Prime Power Switch

Input: A positive integer n=p^q where p and q are prime. Output: Output the result of ...
182 views

Prime decimal representations of prime binary numbers [duplicate]

Problem Statement: Consider a number n in base-10. Find the smallest base-10 integer i greater than ...
5k views

Is it almost-prime?

Sandbox Definition: A positive integer n is almost-prime, if it can be written in the form n=p^k where ...
699 views

Prime Challenge

CODE GOLF & Coding Challenges: In today's challenge, you'll be asked to print the following very special AND tricky AND satisfying Prime Number...! Are you golfers ready? ...
638 views

Prime Modified Z-Factorials

Let me explain one by one the above terms... We will call $\text{Z-Factorial}(n)$ of a positive integer $n$, $n!$ (i.e. $n$ factorial) without any trailing zeros. So, $\text{Z-Factorial}(30)$...
3k views

Legendre's (Unsolved) Conjecture

Legendre's Conjecture is an unproven statement regarding the distribution of prime numbers; it asserts there is at least one prime number in the interval $(n^2,(n+1)^2)$ for all natural $n$. The ...
881 views

Find all Belphegor primes

A Belphegor number is a number of the form $(10^{n+3}+666)*10^{n+1}+1$ (1{n zeroes}666{n zeroes}1) where $n$ is an non-negative integer. A Belphegor prime is a ...
1k views

Generate *all* coprime tuples

Given integers k and n, generate a sequence of n unique k-tuples of pairwise coprime ...
863 views

Draw the prime race tracks

Odd prime numbers are either in the form of 4k+1 or 4k+3 where k is a non-negative integer. ...
302 views

Produce all even primes

A prime number is a positive integer that has exactly two divisors 1 and the number itself. For example number 7 is a prime since it is divisible by 1 and 7. Number 1 is not a prime since it has only ...
326 views

125 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$ ...
425 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). ...
635 views

Make some Prime Squares!

What is a Prime Square? A Prime Square is a square where all four edges are different prime numbers. But which ones? And how do we construct them? Here is an example of a 4x4 Prime Square ...
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 ...
7k 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 ...
913 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 (...
708 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'$ ...
428 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 ...
141 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 ...
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$, ...