# Questions tagged [primes]

For challenges about identifying and manipulating prime numbers

264 questions
Filter by
Sorted by
Tagged with
3k views

### Prime Nerd Sniping Pattern

Longest day of the year - here's something to waste the extra time... Overview Note this is not a popularity contest and not a graphical output challenge - you are only required to output a string ...
1k views

### Recursive Prime Factorization

Your job is to take the prime factors of a number taken from input (omitting any exponents equal to 1) then take the prime factors of all of the exponents, and so on, until no composite numbers remain;...
285 views

### Number of ways to sum [1..n] with [n+1..2n] such that each sum is prime

Let n > 0. Let X = [1..n] and Y = [n+1 .. 2n]. Define ...
3k views

### List Sophie Germain primes

The Question A Sophie Germain prime is a prime p such that 2p+1 is prime as well. For example, 11 is a Sophie Germain prime because 23 is prime as well. Write the shortest program to calculate Sophie ...
2k views

### Factoring a 64-bit integer

Write a GOLF assembly program that reads an integer from stdin (followed by a trailing newline), and outputs its prime factors seperated by newlines, followed by a trailing newline on stdout. The ...
927 views

### Prime polynomials

Given a polynomial, determine whether it's prime. A polynomial is ax^n + bx^(n-1) + ... + dx^3 + ex^2 + fx + g, where each term is a constant number (the ...
780 views

### Self-shortening Prime Tester

Let's get right in to it. Your challenge is to make a program that does these things depending on its input: If the input is a number, output "Prime" if the number is a prime number and "Not prime" ...
826 views

### Finding Programs in the Primes

Let's assign the numbers 0 through 94 to the 95 printable ASCII characters: ...
3k views

### Finding prime numbers without using “prime characters”

Your task, if you choose to accept it, is to write a program/function that accepts an integer N as input. The program/function should output/return a list of the first N prime numbers. But here's the ...
2k views

### Recognize Twin Primes by Crashing [closed]

Background Story Bob was handed the following assignment for his programming class. Please note: this is not the actual challenge. Homework assignment 11: Twin primes Input: an integer ...
683 views

### Factorize it! …badly

A curious kid uses a program which can factorize a number or an expression into the following form: p1^e1 * p2^e2 * ... * pn^en. Exponents equal to ...
836 views

### Pair-golfing Twin primes and the Collatz sequence

This is a new kind of challenge inspired by the Recover the mutated source code problem. You should write two programs or functions both in the same language. The first one should solve Task #1 and ...
2k views

### Cops and Robbers bowling (Robbers)

Robbers' Thread In this challenge, your goal is to crack some code written by the Cops (their code is here) by modifying it. You have cracked their code if: Your modified code has a maximum ...
3k views

### Cops and Robbers bowling (Cops)

Cops' Thread In this challenge, your goal is to write a function that accepts a integer N, and that function will return the first ...
2k views

### All primes from 0 to 1000

Is it possible to make this C code smaller? It prints out all primes from 0 to 1000. C, 89 chars ...
3k views

### Find the largest fragile prime

Consider the function Remove(n, startIndex, count) that removes count digits from the number ...
377 views

### Preprocessing primality

The challenge: Given an integer N, 1 < N < 2³¹, write code that uses the C preprocessor to determine whether N is prime, and produces a "Hello world" program if N is prime, or an error ...
1k views

### Build a Primitive Root Diffuser

Introduction When a room has bare, parallel walls, it can create unpleasant repeating acoustic reflections (echoes). A diffuser is a device mounted on a wall which creates a blocky surface of many ...
2k views

### Shortest code to find next prime palindrome

I was trying to find the shortest code possible that given a number n, returns the next prime palindrome number (limited to below 100000). If the number itself is a prime palindrome, the code should ...
1k views

### Combinatorial products of unique primes

Statement of problem Given a set of unique, consecutive primes (not necessarily including 2), generate the products of all combinations of first powers of these primes — e.g., no repeats — and also 1....
854 views

### Anagramming Code

Let's try this again. The object of this contest is to make two pieces of code that are anagrams of each other (the two must contain the same bytes in a different order), and they will do the ...
2k views

### These Primes of Mine Are Always Solid Lines

Let's create a N×N grid of spaces and underscores that can be used to visually determine if a number is prime. (N may be any positive integer.) This grid has three simple rules: The nth column ...
12k views

### Find the Smoothest Number

Your challenge is to find the smoothest number over a given range. In other words, find the number whose greatest prime factor is the smallest. A smooth number is one whose largest prime factor is ...
1k views

### Find the craftiest prime

Intro Consider the process of taking some positive integer n in some base b and replacing each digit with its representation in the base of the digit to the right. If the digit to the right is a 0, ...
429 views

### Primality Testing in Manufactoria

Background Manufactoria is a game about programming. The player must use a form of two-dimensional programming language to complete tasks. If you've never heard of it, the easiest way to learn is to ...
1k views

### is_gaussian_prime(z)?

Task Write a function that accepts two integers a,b that represent the Gaussian integer z = a+ib (complex number). The program ...
318 views

### Find prime which is generating longest primes sequence using p(n+1)=(p(n)^2+1)/2

Consider following recurrence relation: p[n + 1] = (p[n]^2 + 1) / 2 If p, p, ..., <...
5k views

### Find the largest prime whose length, sum and product is prime

The number 113 is the first prime whose length 3 is prime, digital sum 5 = 1 + 1 + 3 is ...
1k views

### Palindromic prime

I'm solving task, where: Input: A number as an integer. Output: The closest greater palindromic prime as an integer. I would appreciate hints how to make my solution shorter. Or directions if ...
4k views

### Determine if a number is prime without using arithmetic [duplicate]

Write a program which determines if a given number is prime. The catch: No digits or arithmetical operators. This means: No digits from 0 to ...
3k views

### Calculate prime gaps

Finding primes is a programming rite of passage and very frequently a first serious program someone crates (usually with trial division). But primes alone are already worn out. A next far more ...
585 views

### Output the first 200 primes using TeX

Write a plain TeX program that lists the first two hundred primes (in base-10 notation). Including external files/resources is not permitted. The output may be to the terminal, the log file, or the ...
1k views

### Find the smallest prime from a substring

In 1946 Erdos and Copeland proved that a certain number is a normal number, i.e. the digits in its decimal expansion are uniformly distributed. Users will input a sequence of digits and you will find ...
2k views

### Is it a prime? w/o math [closed]

Write a program or function in any language that tells if the input is a prime number. The input is a string representing a natural number in base-10. The output is one of the two strings "Prime" or "...
4k views

### Goldbach's conjecture

Write a program that prompts the user for an even integer greater than 2. Given Goldbach’s conjecture that every even integer greater than 2 can be expressed as the sum of two primes, print out two ...
191 views

### Quine with prime sourcecode character distribution constraints

Your program should take no input, and no network or other connections. Your program should output it's sourcecode. The sourcecode must consist of 3 types of characters: Numeric (0-9), Alpha (a-z|A-Z) ...
826 views

### Circular primes

Given a number determine if it is a circular prime. A circular prime is a prime where if you rotate the digits you still get prime numbers. 1193 is circular prime because 1931 and 9311 and 3119 are ...
489 views

### Enumerate the primes using only unary arithmetic

Write a program which prints the sequence of prime numbers. The shortest solution wins! All numbers must have a unary representation (not just in the output, but throughout the entire program). This ...
1k views

### Nth K-Ugly Number

Write the shortest code in any language of your choice to find the Nth K-ugly number. A K-ugly number is a number whose only prime factors are the prime numbers <= K. This K-ugly number is ...
75 views

### Fastest way to generate Smarandache–Wellin number [duplicate]

Given a number n find the Smarandache–Wellin number for n. Ex: for n=2 output=23 for n=5 output=235711 Answer it in ruby or python. given constraints are n<=70000
1k views

### Evaluate the primorial of a number [duplicate]

The primorial of a number is the product of all the primes until that number, itself included. Take a number from STDIN as the input and evaluate its primorial, ...
2k views

### Find largest prime which is still a prime after digit deletion

Over at https://math.stackexchange.com/questions/33094/deleting-any-digit-yields-a-prime-is-there-a-name-for-this the following question is asked. How many primes are there that remain prime after you ...
14k views

### Fastest code to find the next prime

The problem is as follows. Input: An integer n Output: The smallest prime bigger than n. The challenge is to give the ...
13k views

### Fastest semiprime factorization

Write a program to factorize a semi-prime number in the shortest amount of time. For testing purposes, use this: 38!+1 (523022617466601111760007224100074291200000001) It is equal to: ...
964 views

### Transposed, primes, oh my!

The task is simple: your program reads an integer as an input, and prints whether it is a prime or not. You can print "yes/no", "true/false" or anything what unambiguously identifies the result. The ...
493 views

### List ALL prime-factorized natural numbers in ANY order

This is a variant of List prime-factorized natural numbers up to N in ascending order, but the solutions can be very different. Write a program that outputs prime factorizations of all natural ...
1k views

### List prime-factorized natural numbers up to N in ascending order

For a given n list prime factorization of all natural numbers between 1 and n in ascending ...
3k views

### Find the nth Fibonnaci Prime, in the shortest code

The challenge is rather simple: Take a positive whole number n as input. Output the nth Fibonacci prime number. Input can be ...