The challenge involves mathematics. Also consider using more specific tags: [number] [number-theory] [arithmetic] [combinatorics] [graphs] [geometry] [field-theory].

learn more… | top users | synonyms

9
votes
7answers
758 views

I only pay with dollars

As the title -- although discretely -- hints, I only pay with dollars. The challenge Write a function/program that takes a string as input, which is a monetary value preceded by a symbol. ex) £4.99....
9
votes
10answers
311 views

Derivative at the Edge

My preferred way to approximate a derivative is the central difference, its more accurate than forward difference or backward difference, and I'm too lazy to go higher-order. But the central ...
10
votes
2answers
284 views

Prove that a Number is Algebraic

Inspired by this answer (emphasis mine): We will play a game. Suppose you have some number x. You start with x and then you can add, subtract, multiply, or divide by any integer, except zero. You ...
18
votes
26answers
2k views

Count Up, Replace, Repeat!

Definition Define the nth array of the CURR sequence as follows. Begin with the singleton array A = [n]. For each integer k in A, replace the entry k with k natural numbers, counting up from 1 to k....
7
votes
4answers
214 views

Count, Replace, Add Up! [duplicate]

Definition Define the nth term of the CRAU sequence as follows. Begin with the singleton array A = [n]. Do the following n times: For each integer k in A, replace the entry k with k natural ...
26
votes
35answers
2k views

Difference of the square of the sum

Find the difference between the square of the sums and sum of the squares. This is the mathematical representation: (∑n)^2-∑n^2 Your program/method should take two inputs, these are your lower ...
16
votes
9answers
929 views

g​o​l​f​ ​a​t​a​n​2

Sometimes it really is a struggle to convert cartesian coordinates (x,y) to polar coordinates (r,phi). While you can calculate r = sqrt(x^2+y^2) quite easily, you often need some distinction of cases ...
6
votes
11answers
297 views

Parity of Nth Term in Fibonacci Integer Sequences

If you look at the Fibonacci Numbers, you will notice a pattern in their parity: 0, 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 , 55 , 89 , 144. Every three numbers is even, and all the others are odd. This ...
20
votes
4answers
524 views

Rotate a hypercube

Introduction A hypercube/tesseract is the 4 dimensional equivalent of a normal cube. It's made by taking a cube net, extending it to the 3rd dimension, then – using the 4th dimension – folding it ...
2
votes
0answers
48 views

Does the triangle contain the origin? [duplicate]

Challenge description On a Cartesian plane, a triangle can be described as a set of three points, each point being one of the triangle's vertices. For instance, coordinates (2, 1), (6, 8), (-7, 3) ...
15
votes
12answers
1k views

“Bit-borrow” two numbers

Did you know that a small number can borrow bits from a larger number? Here's an example. Let's say our two numbers 5 and 14. First, write them out in binary: 5 14 000101 001110 First we ...
6
votes
1answer
186 views

Golf the Inverse of Exponential Generating Function

Earlier, we talked about exponential generating functions (e.g.f.). Task You will take a few terms of a sequence. Your task is to find another sequence with that many terms, whose e.g.f., when ...
13
votes
13answers
769 views

Golf the Sequence whose Exponential Generating Function is tangent

Almost every function can be expressed as a polynomial with infinite terms. For example, e^x = 1 + x + x^2/2! + x^3/3! + x^4/4! + ... For example, sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ... The ...
30
votes
22answers
2k views

Leyland Numbers

Given a natural number n, return the n-th Leyland number. Leyland Number Leyland numbers are positive integers k of the form k = x^y + y^x Where x,y are integers strictly greater than 1. They ...
2
votes
29answers
4k views

The handshake problem

The handshake problem is the classic problem that for n people in a room, if they all shake hands, what's the total number of handshakes that occur. You code should take an input of any number and ...
34
votes
27answers
7k views

Weapons of Math Instruction

Last time when I tried to come up with something easy that wasn't a duplicate, it ended up being way too hard.. So hopefully this time it's indeed something newcomers can try as well. Input: An ...
28
votes
15answers
2k views

Turn an Array into a Math Problem

Given a nonempty list of nonnegative integers, consider rewriting it as an arithmetic problem where: A plus sign (+) is inserted between pairs of numbers that increase from left to right (a.k.a. ...
5
votes
7answers
298 views

Ain't there nothing up my sleeves

Note: reference to Nothing up my sleeve number. Your task is to take no input and generate this exact output: d76aa478 e8c7b756 242070db c1bdceee f57c0faf 4787c62a a8304613 fd469501 698098d8 ...
4
votes
10answers
500 views

Compute the Discrete Fourier Transform

Implement the Discrete Fourier Transform (DFT) for a sequence of any length. This may implemented as either a function or a program and the sequence can be given as either an argument or using ...
7
votes
8answers
219 views

Dot Product of Diagonals

This challenge is very simple. You are given as input a square matrix, represented in any sane way, and you have to output the dot product of the diagonals of the matrix. The diagonals in specific ...
12
votes
21answers
1k views

Approximation of e

We all know that the Euler's constant, denoted by e, to the power of some variable x, can be approximated by using the Maclaurin Series expansion: By letting x equal 1, we obtain Challenge ...
28
votes
32answers
1k views

Return the integers with square digit-sums

Introduction and Credit We all know and love our awesome rules to test whether a number is divisble by 11 or 3, which is just some clever sum over the digits of the number. Now this challenge takes ...
22
votes
21answers
1k views

Sum It Up with a Digital Triangle

Well, sum it down really. Write a program or function that takes in a nonempty list of decimal integers (0-9) and outputs a downward pointing "triangle" of digits with the input list at the top where ...
27
votes
22answers
2k views

Pseudofactorial

There is a rather curious number which shows up sometimes in math problems or riddles. The pseudofactorial(N) is the least-common-multiple of the numbers 1 through N. For instance pseudofactorial(7) =...
35
votes
16answers
3k views

Has My Pie Been Bisected?

Write a program or function that takes in a nonempty list of positive integers. You may assume it is input in a reasonable convenient format such as "1 2 3 4" or [1, 2, 3, 4]. The numbers in the ...
12
votes
2answers
133 views

Self Referential Polynomials

For every given degree n it is possible to construct (at least one) an integral polynomial p such that p(k) (p evaluated in k) is the coefficient of the term x^k in the polynomial for all 0 <= k &...
11
votes
6answers
449 views

Longest arithmetic subsequence

Given a non empty finite sequence of integers, return an arithmetic subsequence of maximal length. If there are multiple of the same maximal length, any of them can be returned. Definitions: An ...
15
votes
42answers
1k views

Alternating Sign Sequence

Introduction The sign of a number is either a +, or a - for every non-zero integer. Zero itself is signless (+0 is the same as -0). In the following sequence, we are going to alternate between the ...
5
votes
5answers
282 views

Make the lowest number square that equals n

A number square containing the values 1, 2, 3, 4 looks like this: 12 34 To work out what a number square is, you first make four numbers by reading across the rows and across the columns; for the ...
16
votes
20answers
3k views

Female and Male Sequences

This question is probably harder than all of those "generate a sequence of numbers" tasks, because this requires TWO sequences working in unison. Really looking forward to the answers! In his book "...
25
votes
35answers
2k views

Mean bits: an average challenge

Given an integer N >= 1, output the mean number of bits in an integer from 0 to N - 1 Specification The output can be calculated as the sum of the number of bits in the binary representation of ...
11
votes
7answers
406 views

Find a function with cycles of every length

A function is said to have a cycle of length n if there exists an x in its domain such that fn(x) = x and fm(x) ≠ x for 0 < m < n, where the superscript n denotes n-fold application of f. Note ...
23
votes
6answers
2k views

Golf a golf-scorer

As a kid, I used to play the card game "golf" a lot. Your challenge, should you choose to accept it, is to calculate the score of a golf hand. Since there are over 9000 variations on this card game1, ...
21
votes
23answers
972 views

Divisor reduction

A divisor of a number n is any number that evenly divides n, including 1 and n itself. The number of divisors d(n) is how many divisors a number has. Here's d(n) for the first couple n: n divisors ...
31
votes
17answers
2k views

Print the nth prime that contains n

This question will be a twist on finding the nth prime number. Challenge You must write a program that will take one input n, and output the nth prime number whose decimal representation contains ...
8
votes
8answers
321 views

Calculate the Numpad Taxicab

Credit goes where credit is due Given two digits, x, and y, calculate the shortest number of horizontal or vertical jumps to get from x to y on a standard numpad, e.g. 789 456 123 00 You can ...
20
votes
17answers
2k views

How should you arrange your chairs?

You teach a class of students with interesting preferences for how their chairs are arranged. There are 3 very specific requirements they have for how the chairs are arranged: They most be arranged ...
11
votes
2answers
258 views

What's the chance that I'll win a door prize?

My local ACM chapter gives out door prizes to people who come to the meetings. You get an increased chance of winning if you solve the programming puzzle, however (but I always solve that puzzle). ...
10
votes
11answers
728 views

Discrete Convolution or Polynomial Multiplication

Given two non empty lists of integers, your submission should calculate and return the discrete convolution of the two. Interestingly, if you consider the list elements as coefficients of polynomials, ...
21
votes
33answers
4k views

Smallest integers after N divisible by 2, 3, and 4

Give credit to whom credit is due. Objective Given an integer N > 0, out the smallest integers A, B, and C so that: All of A, B, and C are strictly greater than N; 2 divides A; 3 divides B; and ...
11
votes
1answer
241 views

How many squares are there?

This challenge is inspired by a picture that often roams on Facebook that looks like this. Except our base square will look more like this: ┌─┬───┬─┐ ├─┼─┬─┼─┤ ├─┼─┴─┼─┤ ├─┼─┬─┼─┤ └─┴─┴─┴─┘ The ...
13
votes
13answers
2k views

Fibonacci products

You can decompose a number greater than 0 as a unique sum of positive Fibonacci numbers. In this question we do this by repeatedly subtracting the largest possible positive Fibonacci number. E.g.: 1 =...
37
votes
13answers
5k views

Universal Spooky Meme Translator

Introduction Turns out, aliens love memes just as much as we do. Every alien race we've encountered so far has their own version of 2spooky4me (see the following question) and equivalent, though, ...
26
votes
40answers
4k views

Zeroes at the end of a factorial

Write a program or function that finds the number of zeroes at the end of n! in base 10, where n is an input number (in any desired format). It can be assumed that n is a positive integer, meaning ...
9
votes
8answers
2k views

Do these squares overlap?

Given the coordinates of the upper left corners of two squares and their side lengths, determine whether the squares overlap. A square includes the top and left lines, but not the bottom and right ...
6
votes
6answers
176 views

Find how many pair elements sums up to N [closed]

Based on a recent question in StackOverflow Write a program/function that takes in one ARRAY/list and returns the number of pair-values which sums up to a given TOTAL. Explaining TOTAL=4, ARRAY=[1,...
14
votes
4answers
634 views

Actually Integer Metagolf

Background Actually (the successor to Seriously) is a stack-based imperative golfing language I created in November of 2015. Like many other golfing languages, it has one-byte commands that perform ...
9
votes
4answers
477 views

Calculate the Fermat Point of a Triangle

This is somewhat similar to The centers of a triangle, but with a different point. The Fermat Point is the point P in triangle ABC such that the value of AP + BP + CP is minimized. There are two cases:...
42
votes
27answers
3k views

How many steps does it take from n to 1 by subtracting the greatest divisor?

Inspired by this question over at Mathematics. The Problem Let n be a natural number ≥ 2. Take the biggest divisor of n – which is different from n itself – and subtract it from n. Repeat until ...
11
votes
3answers
463 views

Laver table computations and an algorithm that is not known to terminate in ZFC

The Laver tables provide examples of programs which have not been shown to terminate in the standard axiomatic system of mathematics ZFC but which do terminate when one assumes very large cardinal ...