Tagged Questions
12
votes
19answers
878 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]
...
4
votes
7answers
596 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 ...
5
votes
8answers
425 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
23answers
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 ...
5
votes
7answers
4k 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 ...
0
votes
16answers
661 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
780 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 ...
1
vote
10answers
462 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
5answers
490 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 ...
5
votes
2answers
298 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 ...
7
votes
13answers
684 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 ...
6
votes
6answers
440 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 ...
4
votes
10answers
372 views
Find prime factors
A whole program to find the prime factors of a given number. The number will be given on standard input.
13
votes
22answers
973 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
...