Questions tagged [primes]

For challenges about identifying and manipulating prime numbers

Filter by
Sorted by
Tagged with
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
651 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 ...
17
votes
11answers
2k views

Find Recursively Prime Primes

The Recursively Prime Primes is are sequence of primes such that p(1) = 2 p(n) = the p(n-1)th prime Here is an example of how one might calculate the 4th ...
16
votes
9answers
856 views

Smallest multiplier that reveals a factor of a semiprime

Given a semiprime N, find the smallest positive integer m such that the binary representation of one of the two factors of N can be found in the binary representation of N * m. Example Let's ...
6
votes
3answers
307 views

Closest Woodall Prime

A Woodall Prime is a prime which can be calculated, given a positive integer n, with n * 2^n - 1. Your task is to, given a ...
26
votes
21answers
2k views

Smallest n-digit prime containing only these digits

You will need to generate the smallest prime with n digits, and it will only contain digits specified in the list k. Examples: ...
28
votes
12answers
1k views

Prime Divisor Table

Intro Something I've played around with in recreational mathematics has been construction of a divisor table to visually compare/contrast the prime divisors of a set of numbers. The set of input ...
23
votes
20answers
2k views

Find the Maximal Prime Powers

A prime power is a positive integer n that can be written in the form n = pk where p is a prime and k is a positive integer. For example, some prime powers are ...
15
votes
25answers
4k views

The program that will find the next prime number

Intro: You accidentally corrupted the flow of time with a device you made for fun, that turned out to be a time machine. As a result, you got pushed to the far future. You realized that computing, ...
22
votes
5answers
879 views

Fastest Home Prime Generator

What is a home prime? For an example, take HP(4). First, find the prime factors. The prime factors of 4 (in numerical order from least to greatest, always) are 2, 2. Take those factors as a literal ...
21
votes
32answers
1k views

A prime test that's LITERALLY prime

Write a program that will test the primality of a specified number, and give the output as a Boolean value (True is prime). Your prime test can (but doesn't have to) be valid for the number 1. Here'...
25
votes
16answers
1k views

Approximate Brun's Constant

Brun's constant is the value to which the sum of the reciprocals of twin prime pairs (1/p and 1/(p+2) where ...
23
votes
26answers
2k views

Primes with prime bit-counts

Task Find all the non-negative integers up to and including a given non-zero positive integer n, that are prime and the count of 1's and ...
13
votes
3answers
252 views

The highest prime factor of neighboring numbers

I think it's easiest to explain this challenge in a sequential manner. Start with an input number N and: Find its highest prime factor Check numbers above and below N and see if the highest prime ...
9
votes
1answer
281 views

Negative XOR primes

About a year ago you were asked to find the XOR primes. These are numbers whose only factors are 1 and themselves when performing XOR multiplication in base 2. Now were are going to spice things up ...
33
votes
17answers
3k views

Smallest Prime with a Twist (A068103)

The task at hand is, given a number n, find the smallest prime that starts with AT LEAST n of the number ...
41
votes
15answers
5k views

Determine whether a number is 2017-friable without primes in your source code

Out of all the years I've been making this challenge, 2017 is the first year that's been a prime number. So the question will be about prime numbers and their properties. Your task is to produce a ...
23
votes
1answer
337 views

It's factors all the way down!

This challenge is inspired by this fantastic animated diagram (thanks to flawr for posting it in chat). Given an input n, draw all of its prime factors as nested ...
16
votes
1answer
731 views

Every prime bit must alternate

A program is bit primed if bits in prime positions must alternate between zero and one, starting with one. For example, this is a template for a bit primed program with [0..47] bits. ...
50
votes
43answers
5k views

Coprimes up to N

Given a number n >= 2, output all the positive integers less than n where gcd(n, k) == 1 (...
27
votes
33answers
2k views

Calculate the prime factors

We had a prime factorization challenge a while ago, but that challenge is nearly six years old and barely meets our current requirements, so I believe it's time for a new one. Challenge Write a ...
35
votes
34answers
3k views

Is it a Mersenne Prime?

A number is a Mersenne Prime if it is both prime and can be written in the form 2n-1, where n is a positive integer. Your task is to, given any positive integer, determine whether or not it is a ...
12
votes
11answers
897 views

The negative order integer challenge, but it's Prime Time!

Im talking about this question, take a look at it if you are a bit confused. Main Task Your task is to output concatenated integers, in decreasing order, but increasing the maximum integer everytime ...
7
votes
4answers
199 views

The Primitive and Basic Numbers

Your task is to generate the "Primitive and Basic" numbers, which are made like so: Start with 110. Take the digits of its base-1 representation (110 = 11) and interpret them as base-2 digits. This ...
8
votes
9answers
501 views

Every nth prime number up to 8675309

Read this if you're confused. Challenge: The goal of this code-golf is based around the number 8675309... Your goal is to print out every prime number from 2 to ...
34
votes
14answers
1k views

Generate n-ary numbers

A secondary number is a positive integer whose prime factors (without multiplicity) are all less than or equal to its square root. 4 is a secondary number, because ...
18
votes
19answers
869 views

Print the missing primes

The Task Write a program or function that, when passed a numerical input x, prints or returns the primes beneath the square root of ...
16
votes
1answer
333 views

Nostalgic prime number generator [closed]

Remember the good old days when opening a simple document or web page was painfully slow as it hogged all the meager resources your computer had? And today, doing the same is even slower, despite your ...
33
votes
19answers
2k views

Finding The nth Prime such that the prime - 1 is divisible by n

Problem The goal is as the title says to find the nth prime such that the prime - 1 is divisible by n. Explanation Here is an example so you understand the question, this is not necessarily the ...
19
votes
12answers
1k views

Find the Emirps!

An emirp is a non-palindromic prime which, when reversed, is also prime. The list of base 10 emirps can be found on OEIS. The first six are: ...
27
votes
21answers
1k views

Primenary Strings

A Primenary (binary-prime) string is one which, when written as a binary grid, every row and column has a prime total. That's quite a vague explanation, so let's break it down with a worked example.....
13
votes
2answers
4k views

Primes with a twist

Note: this is heavily inspired by this question. Task: Your task is to generate the nth prime, when each character of your program is repeated ...
18
votes
13answers
676 views

Goldbach partitions

The Goldbach conjecture states that every even number greater than two can be expressed as the sum of two primes. For example, 4 = 2 + 2 6 = 3 + 3 8 = 5 + 3 ...
15
votes
12answers
2k views

Sieve of Eratosthenes, Step by Step

Given a number N, draw a left aligned NxN board of numbers, leaving 1 blank (as a space) (I will show diagrams with N=5) ...
14
votes
8answers
614 views

The 3x3 Hexa Prime Square Puzzle

The 3x3 Hexa Prime Square Puzzle Introduction We consider 3x3 squares of hexadecimal digits (from 0 to F) such as: ...
18
votes
19answers
2k views

Compute the Mertens function

Given a positive integer n, compute the value of the Mertens function M(n) where and μ(k) is the Möbius function where μ(k) = 1 if k has an even number of distinct prime factors, -1 if k has an odd ...
24
votes
9answers
2k views

The Solitude of Prime Numbers

Recently I read the novel "The Solitude of Prime Numbers" where the main characters are somewhat compared to twin prime numbers ("always together, but never touching"). A twin prime is a prime ...
28
votes
41answers
2k views

Prime counting function

Introduction The Prime Counting Function, also known as the Pi function \$\pi(x)\$, returns the amount of primes less than or equal to x. Challenge Your program will take an integer x which you ...
21
votes
10answers
1k views

Prime factors buddies

Given an integer N > 1, output all other numbers which prime decompositions have the same digits as the prime decomposition of ...
36
votes
20answers
5k views

Compute the Carmichael function

Task description In number theory, the Carmichael function λ takes a positive integer n and returns the least positive integer k so that the k-th power of each integer coprime to n equals 1 modulo n. ...
26
votes
22answers
4k views

Can the number reach 1 by repeatedly subtracting the largest prime less than it?

Challenge: Given a number, take the largest prime strictly less than it, subtract it from this number, do this again to this new number with the biggest prime less than it, and continue doing this ...
11
votes
6answers
611 views

Products of Consecutive Primes

As of time of submission to the sandbox, I had 17017 reputation, which you will all be able to factorise as 7×11×13×17, a product of 4 consecutive primes. Please write a function or program to output ...
18
votes
21answers
1k views

Excessive Integers

For a positive integer n with the prime factorization n = p1^e1 * p2^e2 * ... pk^ek where ...
18
votes
19answers
1k views

Variable Prime “Twins”

I am 2/3 twins with my brother, i.e. born on the same day of the same month but twelve years later. When I was 5, he was 17, both primes; the last pair of ages we can reasonably count on is [71, 83] ...
11
votes
11answers
421 views

Print/Output all positive numbers in which every multi-digit substring in its decimal representation is also prime.

Task Your task is to print or output all positive numbers in which every multi-digit substring in its decimal representation is also prime. If the number has at least 2 digits, this would imply that ...
12
votes
8answers
359 views

Dense Number Sequence

OEIS: A167171 A dense number is a number that has exactly as many prime divisors as non-prime divisors (including 1 and itself as divisors). Equivalently, it is either a prime or a product of two ...
11
votes
2answers
393 views

Right and tfeL truncatable primes

A right-truncatable prime is a prime where every prefix is a prime (in base 10). A left-truncatable prime is exactly the opposite, where every postfix is a prime (primes that start with 0 aren't ...
18
votes
14answers
2k views

Pretty Smooth Moves

In arithmetic, an n-smooth number, where n is a given prime number, is mathematically defined as a positive integer that has no prime factors greater than n. For example, 42 is 7-smooth because all ...
22
votes
14answers
2k views

Prime Wednesdays

Prime Wednesdays Your task is to count the number of Wednesdays that fall on a prime day of the month in a particular year. For instance, 7-13-16 is a prime ...
22
votes
16answers
2k views

Sort a number's divisors by prime factorization

Given an input of an integer ≥ 2, output a list of its divisors sorted by the exponents in their prime factorizations, in ascending order, ordering first by the largest prime, then by the second ...