Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [primes]

For challenges about identifying and manipulating prime numbers

44
votes
22answers
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 ...
-3
votes
3answers
164 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 ...
9
votes
17answers
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 ...
50
votes
18answers
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 : ...
14
votes
33answers
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). ...
16
votes
16answers
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 ...
19
votes
3answers
510 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: ...
9
votes
7answers
806 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 <...
14
votes
18answers
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,...
0
votes
3answers
121 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 ...
17
votes
10answers
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. ...
6
votes
2answers
330 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 ...
38
votes
23answers
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: ...
14
votes
14answers
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 ...
14
votes
14answers
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 ...
5
votes
6answers
522 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 ...
12
votes
28answers
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, ...
35
votes
24answers
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 ...
15
votes
5answers
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 ...
21
votes
22answers
2k views

Get thee behind me Satan-Prime!

Satan-Primes who are they? they are Primes containing 666 these are Satan-Primes:...
30
votes
9answers
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 ...
37
votes
18answers
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 ...
33
votes
11answers
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 ...
33
votes
8answers
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 ...
24
votes
22answers
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 ...
36
votes
17answers
4k views

Primes other than Optimus

Challenge Given an input integer n > 0, output the number of primes (other than n, if n ...
10
votes
10answers
787 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 ...
23
votes
19answers
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 ...
29
votes
36answers
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 ...
28
votes
13answers
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: ...
26
votes
20answers
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 ...
13
votes
28answers
924 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 ...
26
votes
22answers
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 ...
22
votes
20answers
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 ...
7
votes
8answers
378 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 ...
5
votes
7answers
484 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 ...
9
votes
5answers
580 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. ...
24
votes
28answers
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 ...
26
votes
8answers
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 ...
24
votes
20answers
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 ...
14
votes
5answers
905 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 ...
16
votes
3answers
561 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 ...
14
votes
15answers
736 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 ...
39
votes
13answers
5k views

579085261 is CRAZY, 725582 is GOLF, 10757494 is …?

Your task is to translate a 103-smooth number into an English word, using the method described below. How? Generate the list of prime factors (with repetition) of the input number. Sort the list: ...
14
votes
9answers
2k views

Palindromic Primes without 11

Every palindrome with an even number of digits is divisible by 11, so 11 is the only [palindromic prime] with an even number of digits. - David Wasserman, OEIS I learned this today the manual way, ...
19
votes
4answers
705 views

Fermat's factorization helper

We'd like to factorize a semiprime \$N\$. The goal of this challenge is to find two small integers \$u\$ and \$v\$ such that \$uvN\$ can be trivially factorized with Fermat's method, thus allowing to ...
23
votes
14answers
3k views

Reuse your code!

In this challenge we try to solve two important problems at once. They are: Given integers a and b, tell if ab-1 is a prime number. Given integers a and b, return nCr(a, b). Specifically, you must ...
13
votes
13answers
1k views

The Tenacious Thai Calendar

In the Thai calendar the year 2017 corresponds to 2560. The Thai calendar is always 543 years ahead of the Gregorian calendar. Observant coders will note that 2560 is equal to ...
16
votes
15answers
2k views

Additive Primes amongst first x Primes

Definition of Additive Primes: Numbers which have exactly 2 divisors are called Prime numbers. Numbers which are prime and their sum of digits is also a prime number are called Additive Primes Task:...
11
votes
6answers
649 views

Calculate Exponents bit by bit

Your task is to slowly calculate exponentiation, with the following steps: Given two inputs (in this example, 4 and 8), you must calculate the exponentiation by calculate the equation bit by bit. You ...