Linked Questions

88 votes
58 answers
17k views

Tips for golfing in Haskell

What general tips do you have for golfing in Haskell? I am looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Haskell. Please post only one ...
Animesh 'the CODER''s user avatar
49 votes
97 answers
5k views

Division and remainder

This challenge, while probably trivial in most "standard" languages, is addressed to those languages which are so esoteric, low-level, and/or difficult to use that are very rarely seen on this site. ...
Leo's user avatar
  • 12.6k
47 votes
85 answers
8k views

Greatest Common Divisor

Your task is to compute the greatest common divisor (GCD) of two given integers in as few bytes of code as possible. You may write a program or function, taking input and returning output via any of ...
Mike Shlanta's user avatar
55 votes
50 answers
9k views

Coprimes up to N

Given a number n >= 2, output all the positive integers less than n where gcd(n, k) == 1 (...
Riker's user avatar
  • 7,810
72 votes
28 answers
7k views

Calculate Phi (not Pi)

No, I don't mean \$\phi = 1.618...\$ and \$π = 3.14159...\$. I mean the functions. \$\phi(x)\$ is the number of integers less than or equal to \$x\$ that are relatively prime to \$x\$. \$π(x)\$ is ...
El'endia Starman's user avatar
38 votes
23 answers
4k views

Natural Pi #0 - Rock

Goal Create a program/function that takes an input N, check if N random pairs of integers are relatively prime, and returns <...
NonlinearFruit's user avatar
24 votes
28 answers
5k views

The Möbius Function

The Möbius function is an important number theoretic function. Your submission should accept a positive integer \$n\$ and return the value of the Möbius function evaluated at \$n\$. Definition The ...
flawr's user avatar
  • 43.8k
17 votes
34 answers
6k 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, ...
Offtkp's user avatar
  • 3,062
26 votes
20 answers
2k views

Co-primality and the number pi

Introduction Number theory is full of wonders, in the form of unexpected connections. Here's one of them. Two integers are co-prime if they have no factors in common other than 1. Given a number \$N\$,...
Luis Mendo's user avatar
  • 104k
13 votes
21 answers
2k views

Iterated phi sequence

Related: Iterated phi(n) function. Your challenge is to compute the iterated phi function: f(n) = number of iterations of φ for n to reach 1. Where ...
Simply Beautiful Art's user avatar
26 votes
12 answers
2k views

Next Shared Totient

The totient function \$\phi(n)\$, also called Euler's totient function, is defined as the number of positive integers \$\le n\$ that are relatively prime to (i.e., do not contain any factor in common ...
frank's user avatar
  • 991
20 votes
9 answers
21k views

Super speedy totient function

The goal is simple: calculate the totient function for as many numbers as you can in 10 seconds and sum the numbers. You must print your result at the end and you must actually calculate it. No ...
qwr's user avatar
  • 12.1k
8 votes
14 answers
1k views

Golf the repeated totient function

You will take two positive integers n and x as input, and output Euler's totient function (number of positive integers less than ...
Leaky Nun's user avatar
  • 49.7k
11 votes
8 answers
516 views

Draw a phi triangle

Clarification: Basically, you need to make this Euler's totient function has the name phi. Let's try to calculate phi(8) First, list all numbers 8 and under backwards, not including 0 or under <...
user avatar
4 votes
3 answers
276 views

unRSA: solve the private key

Given positive integer n and e, knowing that e<n and that ...
l4m2's user avatar
  • 22.3k