A prime number is a number that is only divisible by 1 and itself.

learn more… | top users | synonyms

11
votes
8answers
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 ...
33
votes
23answers
7k 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 ...
6
votes
5answers
930 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, ...
10
votes
1answer
220 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 ...
10
votes
7answers
762 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 must return true or false depending on whether a+ib is a Gaussian prime ...
-1
votes
2answers
269 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[1], p[2], ..., p[k] are primes and p[k+1] is not, then k is length of sequence starting with p[1]. For example, if p[1] = 3, ...
27
votes
10answers
4k 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 prime, and digital product 3 = 1 * 1 * 3 is prime. A prime that has these 3 properties will be called supremely ...
8
votes
1answer
429 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 ...
12
votes
7answers
3k 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 9, anywhere in the program, and whatever the meaning No ...
14
votes
28answers
2k 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 ...
10
votes
11answers
749 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 ...
11
votes
8answers
1k views

Is it a prime? w/o math

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 ...
13
votes
24answers
1k 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 ...
4
votes
4answers
133 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 ...
3
votes
10answers
616 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 ...
6
votes
5answers
344 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 ...
4
votes
7answers
418 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 ...
0
votes
0answers
59 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
13
votes
19answers
1k views

Give the smallest number that has N divisors

Your function takes a natural number and returns the smallest natural number that has exactly that amount of divisors, including itself. Exemples: f(1) = 1 [1] f(2) = 2 [1, 2] f(3) = 4 [1, 2, 4] ...
15
votes
6answers
1k views

Find largest prime which is still a prime after digit deletion

Over at http://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 ...
6
votes
3answers
3k 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 fastest code possible to do this. I will test the code on values starting at ...
11
votes
2answers
2k 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: ...
2
votes
2answers
340 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 ...
3
votes
2answers
787 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 order. For example, for n = 10 the output would be: 1: 2: 2^1 3: 3^1 4: 2^2 5: 5^1 6: 2^1 3^1 7: 7^1 8: 2^3 ...
6
votes
9answers
1k 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 as an parameter to a function (and the output will be the return ...
0
votes
3answers
458 views

Prime tester + nth-prime finder (TO BE CLOSED) [duplicate]

Possible Duplicate: List of first n prime numbers most efficiently and in shortest code This is to be closed soon - please don't answer (mod- please close!) This challenge is to write the ...
5
votes
8answers
510 views

Square-free semiprime counting

Definition A square-free semiprime is a natural number that is the product of two distinct prime numbers. The task Given a natural number n, count all square-free semiprimes less than or equal ...
3
votes
24answers
1k views

Sexy Primes — codegolf

Write the shortest code to print sexy primes till n Sexy Primes are pairs of numbers (n, m) such as n and m both are prime, and m = n + 6. EDIT Modifying the question a little bit after reading ...
11
votes
9answers
8k views

List of first n prime numbers most efficiently and in shortest code

Rules are simple: First n primes (not primes below n), should be printed to standard output separated by newlines (primes should be generated within the code) primes cannot be generated by an ...
18
votes
52answers
3k views

List of primes under a million

This is my first code golf question, and a very simple one at that, so I apologise in advance if I may have broken any community guidelines. The task is to print out, in ascending order, all of the ...
10
votes
7answers
906 views

Sum of (at most) 5 primes

Terence Tao recently proved a weak form of Goldbach's conjecture! Let's exploit it! Given an odd integer n > 1, write n as a sum of up to 5 primes. Take the input however you like, and give ...
3
votes
10answers
602 views

Return the first N primes

With a twist; your algorithm has to be less complex than O(X2) where X is the Nth prime. Your solution post should include the character count and the theoretical complexity in terms of X (or N, which ...
-2
votes
2answers
225 views

Numbers that are divisible by at least three different primes [closed]

I was studying different sequences related to prime numbers and came across this sequence: A000977: Numbers that are divisible by at least three different primes. Write code to find the n-th number ...
3
votes
5answers
736 views

Show Ulam's spiral

Similar to this but in this one you need to write spiral starting from the center where: space means composite number .(dot) means prime number. Size of the spiral can be given as parameter or on ...
6
votes
2answers
800 views

Find 10 large prime numbers with n digits

You are given n (200 ≤ n < 250) as a command line argument. Print 10 prime numbers with n digits. Your program should run under 1s and must be shorter than 5000 bytes (excluding). Sum the ...
7
votes
2answers
386 views

The Prime Grid Game

I had fun solving this, so i offer this golf challenge. The objective of this golf is to find the largest prime number that can be constructed using the given instructions. You should accept 3x3 ...
6
votes
4answers
894 views

Code-Challenge:The Nearest Prime

Challenge In this task you would be given an integer N you have to output the nearest prime to the integer. If the number is prime itself output the number. The input N is given in a single ...
9
votes
13answers
837 views

Factorize me!!!

In this task, you have to write a program, that computes the prime factors of a number. The input is a natural number 1 < n < 2^32. The output is a list of the prime factors of the number in the ...
10
votes
6answers
680 views

What is the average of n, the closest prime to n, the square of n and the closest fibbonacci number to n?

This is a math problem which takes quite many things into question, making it rather challenging, and as you might have guessed, it's a code golf, so it should be as short as possible as well. The ...
8
votes
18answers
680 views

Find prime factors [duplicate]

A whole program to find the prime factors of a given number. The number will be given on standard input.
19
votes
28answers
2k views

Sum of primes between given range

Write the shortest code for finding the sum of primes between a and b (inclusive). Input a and b can be taken from command line or stdin (space seperated) Assume 1 <= a <= b <= 108 ...