# Questions tagged [primes]

For challenges about identifying and manipulating prime numbers

265 questions
Filter by
Sorted by
Tagged with
1k views

### Repeated Digit Primes

Another sequence, another challenge.* Definition A prime p is in this sequence, let's call it A, iff for every digit ...
2k views

### Different ways of defining primes

One of my favorite definitions of the prime numbers goes as follows: 2 is the smallest prime. Numbers larger than 2 are prime if they are not divisible by a smaller prime. However this definition ...
1k views

### Do we share the prime cluster?

The prime cluster of an integer N higher than 2 is defined as the pair formed by the highest prime strictly lower than N and the lowest prime strictly higher than N. Note that following the ...
3k views

### Output the PPCG Prime

This is the PPCG Prime 624 digits long ...
2k views

### Largest Prime Exponents

Given an integer n >= 2, output the largest exponent in its prime factorization. This is OEIS sequence A051903. Example Let ...
8k views

### The prime frog 🐸

The "prime frog" is a strange animal that jumps between integers, until it arrives on 3 or 19... Your program should accept an integer n as input and output the ...
165 views

### Multi-Base Primes [closed]

For the purpose of this challenge, a multi-base prime is a prime which, when written in base 10, is prime in one or more bases smaller than 10 and larger than 1 as well. All single-digit primes are ...
1k views

### Primes in the prime factorisation

I saw another prime challenge coming by in PPCG, and I do love me some primes. Then I misread the introductory text, and wondered what the creative brains here had come up with. It turns out the ...
9k views

### The prime ant 🐜

The "prime ant" is an obstinate animal that navigates the integers and divides them until there are only primes left! Initially, we have an infinite array A containing all the integers >= 2 : ...
2k views

### How many unique primes?

One way to represent a natural number is by multiplying exponents of prime numbers. For example, 6 can be represented by 2^1*3^1, and 50 can be represented by 2^1*5^2 (where ^ indicates exponention). ...
1k views

### Prime Powers of Primes

For the purpose of this challenge, a Prime Power of a Prime (PPP) is defined as a number that can be defined as a prime number to the power of a prime number. For example, 9 is a PPP because it can ...
526 views

### Writing rational numbers as ratio of factorials of primes

Note: this challenge has been posted on the sandbox. Introduction This challenge is inspired by 2009 Putnam B1, a problem in an undergraduate mathematics competition. The problem is as follows: ...
812 views

### Golf the pseudoprimes!

Introduction / Background In a recent discussion in the crypto chat I was challenged to discuss / help with the Fermat primality test and Carmichael numbers. This test is based on the premise that <...
2k views

### Prime Factoral Roots

Inspired by digital roots, the prime factoral root of a number is the number that emerges when you take the prime factors of a number, add them together, and repeat the process on the resulting number,...
122 views

### Prime Factorial [duplicate]

For the purposes of this question, the prime factorial of a number n is the result of multiplying all prime numbers smaller than n, and then multiplying the result by n. Your Task: Write a program ...
1k views

### Numbers with similar powers

Given an integer p > 1, find the smallest integer q > p such that the list of exponents in the prime factorization of q is the same of that of p, no matter the order or the value of the prime factors. ...
331 views

### Build the Trinity Hall Prime

Based on this challenge and this Math.SE question. Idea originally come from a Numberphile video. The goal is to reproduce the logic of Professor McKee when he builds this prime. Your task is to ...
3k views

### Output the Trinity Hall Prime

Based on this Math.SE question; number copied from this answer. Number originally from a Numberphile video, of course. Your task is to output the following 1350-digit prime number: ...
2k views

### Compute the Wilson numbers

Given a positive integer n, compute the nth Wilson number W(n) where and e = 1 if n has a primitive root modulo n, otherwise e = -1. In other words, n has a primitive root if there does not exist an ...
2k views

### Generate strong primes [duplicate]

In number theory, a strong prime is a prime number that is greater than the arithmetic mean of the nearest prime above and below (in other words, it's closer to the following than to the preceding ...
531 views

### Perfect, Germain, Vampire, Mersenne! (Don't forget narcissistic) [duplicate]

Six is a number perfect in itself, and not because God created all things in six days; rather, the converse is true. God created all things in six days because the number six is perfect. I am ...
2k views

### Array Factorization

Given an array of positive integers, output a stable array of the distinct prime factors of these integers. In other words, for each integer in the input in order, get its prime factors, sort them, ...
3k views

### Plus Primes vs Minus Primes

Most of us know... that all primes p>3 are of the form But, how many are the Plus Primes (6n+1) and how many are the ...
365 views

### Primus-Orderus Primes

Who are they? Primus-Orderus Primes (POP) are primes which contain their order in the sequence of primes. So the nth prime, in order to be POP, must contain all ...
2k views

### Get thee behind me Satan-Prime!

Satan-Primes who are they? they are Primes containing 666 these are Satan-Primes:...
3k views

### Find Primes in Pi

Primes are everywhere... they hide inside Pi 3.1415926535897932384626433832795028841971693993751 Let's get those primes! The Challenge Given as input an integer ...
3k views

### Prime Up your code

Input no input for this challenge The Challenge Write a code that outputs: The first 10 prime numbers whose sum of their digits equal the number of bytes of your code Examples Let's say your ...
2k views

### Encode an integer

Given positive integer n > 2. We convert it to an array as follows: If it is equal to 2 return an empty array Otherwise ...
2k views

### No co-prime neighbors

Given a list of positive integers, output whether every adjacent pair of integers in it shares a prime factor. In other words, output truthy if and only if no two neighboring integers in the list are ...
6k views

### Can even numbers become prime?

The Sequence Everyone knows the only even prime number is 2. Ho-hum. But, there are certain even numbers n where, when ...
4k views

### Primes other than Optimus

Challenge Given an input integer n > 0, output the number of primes (other than n, if n ...
791 views

### Generating Fermat primes

Given a number n, print the nth prime Fermat number, where the Fermat numbers are of the form 22k+1. This code should theoretically work for any n (i.e. don't hardcode it), although it is not expected ...
4k views

### Do I have a prime twin?

An Integer is prime if and only if it is positive and has exactly 2 distinct divisors: 1 and itself. A twin prime pair is made of two elements: p and ...
3k views

### Is it a Sphenic Number?

A Sphenic Number is a number that is the product of exactly three distinct primes. The first few Sphenic numbers are 30, 42, 66, 70, 78, 102, 105, 110, 114. This is ...
3k views

### Is it a turtle prime?

As we all know, it's turtles all the way down. But is it primes all the way down too? A number is considered a "turtle-prime" if it satisfies the following conditions: ...
3k views

### Is it a Chen prime?

A number is a Chen prime if it satisfies two conditions: It is prime itself Itself plus two is either a prime or a semi-prime. A prime is a number where it has exactly two divisors and those ...
932 views

### Am I a Sophie Germain prime? [duplicate]

A Sophie Germain Prime is a prime number P such that 2P+1 is prime as well. Given a prime number as input, your task is to determine whether it is a Sophie Germain Prime. Standard Input/Output rules ...
2k views

### Is it a weak prime?

A prime is weak if the closest other prime is smaller than it. If there is a tie the prime is not weak. For example 73 is a weak prime because 71 is prime but 75 is composite. Task Write some ...
2k views

### Is it a super-prime?

Background A super-prime is a prime number whose index in the list of all primes is also prime. The sequence looks like this: 3, 5, 11, 17, 31, 41, 59, 67, 83, 109, 127, 157, 179, 191, ... This ...
382 views

### Find the numbers coprime to their decimal digits

Two numbers are coprime if their greatest common divisor is 1. Given a positive integer N, your task is to compute the first N terms of OEIS A061116, which is the sequence of positive integers ...
516 views

### Golf the Lucas Lehmer Primality Test

your task is to write a program that uses the Lucas-Lehmer primality test to check whether an input number is prime or not. This prime number candidate has the form ...
581 views

### Increasing Goldbach partitions

The Goldbach conjecture states that: every even number that is greater than 2 is the sum of two primes. We will consider a Goldbach partition of a number n to be a pair of two primes adding to n. ...
2k views

### Magnanimous numbers

Given an positive integer as input determine if it is a magnanimous number. A magnanimous number is a number such that any insertion of a + sign between any two ...
1k views

### A083569: Smallest m not occurring earlier such that m+n is prime

Define a 1-indexed sequence as follows: A083569(1) = 1 A083569(n) where n is an integer ...
2k views

### Climb a step to a prime

The title of Numberphile's newest video, 13532385396179, is a fixed point of the following function f on the positive integers: Let n be a positive integer. Write the prime factorization in the ...
909 views

### Golf a bijection within the natural numbers which map the primes to a proper subset of the primes

Definitions A bijection from a set S to a set T is a function from S to ...
582 views

### Miller-Rabin Strong Pseudoprimes

Given a non-negative integer N, output the smallest odd positive integer that is a strong pseudoprime to all of the first N ...
738 views

### Maximal mutually co-prime factorization

Definitions Two numbers are co-prime if their only positive common divisor is 1. A list of numbers is mutually co-prime if every pair of numbers within that list ...