Linked Questions

67 votes
226 answers
17k views

Add two numbers

Input: Two integers. Preferably decimal integers, but other forms of numbers can be used. These can be given to the code in standard input, as arguments to the program or function, or as a list. ...
user avatar
  • 6,217
40 votes
101 answers
5k views

Divisibility test

Task Given two strictly positive integers n and d as input, determine whether n is evenly divisible by d, i.e., if there exists an integer q such that n = qd. You ...
user avatar
  • 48.2k
51 votes
80 answers
9k views

Do n and n^3 have the same set of digits?

Given a number n (0 <= n <= 2642245), check if n and n3 have the same set of digits, and output a truthy or falsey value accordingly. For example, let's check the number 100. 1003 is 1000000. ...
user avatar
  • 10.3k
84 votes
26 answers
18k views

Shortest code to throw SIGILL

Background We already have a challenge about throwing SIGSEGV, so why not a challenge about throwing SIGILL? What is SIGILL? SIGILL is the signal for an illegal instruction at the processor, which ...
user avatar
  • 1,593
35 votes
47 answers
3k views

Least Common Multiple

The least common multiple of a set of positive integers A is the smallest postive integer B such that, for each ...
user avatar
45 votes
33 answers
6k views

Tips for golfing in x86/x64 machine code

I noticed that there's no such question, so here it is: Do you have general tips for golfing in x86/x64 machine code? If the tip only applies to a certain environment or calling convention, please ...
user avatar
  • 16.4k
32 votes
39 answers
5k views

Calculate Euler's totient function

Background Euler's totient function φ(n) is defined as the number of whole numbers less than or equal to n that are relatively ...
user avatar
  • 2,192
29 votes
43 answers
6k views

Convert a 32 bit binary IPv4 address to its quad-dotted notation

Challenge Write a program or function that converts a 32 bit binary number to its quad-dotted decimal notation (often used for representing IPv4) Quad-dotted decimal A quad-dotted decimal is formed ...
user avatar
  • 1,599
38 votes
22 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 <...
user avatar
17 votes
26 answers
2k views

Adding fractions

Write a program or a function that takes two non-empty lists of the same length as input and does the following: uses elements of first list to get numerators, uses elements of the second list to get ...
user avatar
22 votes
14 answers
2k views

The Euclidean Algorithm (for finding the greatest common divisor)

The Challenge Write a program or function that takes two input integers, i and j, and outputs their greatest common divisor; ...
user avatar
  • 6,564
17 votes
12 answers
1k views

Find the tangent of the sum of inverse tangents

Background It can be shown that for any integer k >= 0, f(k) = tan(atan(0) + atan(1) + atan(2) + ... + atan(k)) is a ...
user avatar
14 votes
14 answers
2k views

Compute the Wilson numbers

Given a positive integer n, compute the nth Wilson number W(n) where and e = 1 if n has a primitive root modulo n, otherwise e = -1. In other words, n has a primitive root if there does not exist an ...
user avatar
  • 16.4k
29 votes
8 answers
2k views

Codeium Golfide

In this challenge, your task is to take an anion and a cation, and output the chemical formula of the compound. Input rules Take in 2 strings (in any order) representing the anion and cation, e.g. <...
user avatar
  • 3,566