Questions tagged [math]

The challenge involves mathematics in some central way. Also consider using more specific tags, listed in the tag wiki info.

Filter by
Sorted by
Tagged with
8
votes
5answers
86 views

Output every substring ... eventually

You will be given as input an infinite stream of positive integers. Your task is to write a program which outputs an infinite sequence of lists with two requirements: All lists in the output are ...
16
votes
11answers
2k views

BigNum Bakeoff Reboot

Some of you may be familiar with the BigNum Bakeoff, which ended up quite interestingly. The goal can more or less be summarized as writing a C program who's output would be the largest, under some ...
-1
votes
2answers
150 views

Challenge: create a large number using an esoteric programming language [duplicate]

I enjoy large numbers and esoteric programming language, so I decided to combine them into a programming challenge. Your goal is to push the limits of esoteric languages like BF or Pyth and return the ...
3
votes
9answers
642 views

Generate Fmbalbuena Numbers

My user id is 106959 How to check if the number is Fmbalbuena number? First Step: Check if the number of digits is a multiple of 3: ...
12
votes
12answers
2k views

Round like a Zero

Goal Given an input number, round it off to the nearest number with one significant figure. Requirements Input A floating point number. Assume the input number results in an output within the data ...
6
votes
4answers
649 views

How can I golf this code to count all perfect squares below 100?

I'm trying to strip down my python code to be as few lines as possible. The task: count how many square numbers are below 100. Here's my code so far: ...
30
votes
14answers
2k views

Iterate your way to a fraction

I recently learned from a comment by MathOverflow user pregunton that it is possible to enumerate all rational numbers using iterated maps of the form \$f(x) = x+1\$ or \$\displaystyle g(x) = -\frac ...
-6
votes
4answers
110 views

Indices of square numbers that are also pentagonal [closed]

First 15 numbers of the A046173: ...
8
votes
4answers
710 views

Shortest program to split special array

Background Imagine, you have a big array A, which is mostly zeroes, but contains a short subarray B which has only strictly ...
21
votes
17answers
1k views

Reconstruct a recursively prime-encoded integer

Recursively prime-encoded integers Consider \$11681169775023850 = 2 \times 5 \times 5 \times 42239 \times 5530987843\$. This isn't a nice prime factorisation, as \$42239\$ and \$5530987843\$ make it ...
106
votes
369answers
18k views

One OEIS after another

As of 13/03/2018 16:45 UTC, the winner is answer #345, by Khuldraeseth na'Barya. This means the contest is officially over, but feel free to continue posting answers, just so long as they follow the ...
32
votes
13answers
3k views

That's a prime... almost

If you've ever learned about primes in math class, you've probably have had to, at one point, determine if a number is prime. You've probably messed up while you were still learning them, for example, ...
21
votes
9answers
2k views

Bird's Algorithm for Computing Determinants

There is a division-free algorithm for computing determinants published by R.S.Bird in 2011 that uses only matrix multiplications. Given a \$n×n\$ matrix \$X\$, the matrix \$Y=μ(X)\$ is another \$n×n\$...
20
votes
30answers
3k views

Total cost of The 12 Days of Christmas

Introduction I have decided that this Christmas, as a "present" to a friend, I wish to purchase the things described in the classic song "The 12 Days of Christmas". The only ...
6
votes
12answers
1k views

Print cos(2π/17) exactly

One way to construct a regular heptadecagon starts with drawing a horizontal line of length 1 from the center to a vertex. Then the distance along that line from ...
16
votes
27answers
1k views

Output a unique sign sequence

A sign sequence is an infinite sequence consisting entirely of \$1\$ and \$-1\$. These can be constructed a number of ways, for example: Alternating signs: \$1, -1, 1, -1, ...\$ \$-1\$ for primes, \$...
9
votes
14answers
1k views

ASCII-Plot the equation

You are given a polynomial function, in the following format: \$x = (c_0 * y^0) + (c_1 * y^1) + (c_2 * y^2) + ... + (c_n * y^n)\$ where \$c_n\$ stands for the coefficient of the \$n^{th}\$ power of \$...
6
votes
2answers
240 views

No parentheses shall be omitted

This expression actually has an omitted pair of parentheses. 1 + 2 * 3 To make things clear, it should be, 1 + (2 * 3) Even ...
34
votes
31answers
6k views

How far should I sum?

The harmonic series is the "infinite sum" of all the fractions of the form \$\frac1n\$ for \$n\$ positive integer. I.e. the harmonic series is $$\frac11 + \frac12 + \frac13 + \frac14 + \...
26
votes
7answers
881 views

Recover polynomial \$f(x)\$ from \$f^2(x)\$

Related: Calculate \$f^n(x)\$, Polynomialception Challenge Given a polynomial \$f(x) = a_0 + a_1 x + a_2 x^2 + \cdots + a_k x^k\$ of order \$k\$, we can compute its composition with itself \$f\left(f(...
25
votes
41answers
6k views

Additive Persistence

The shortest code to pass all possibilities wins. In mathematics, the persistence of a number measures how many times a certain operation must be applied to its digits until some certain fixed ...
21
votes
37answers
3k views

Reverse factorial function

Given a number n, find x such that x! = n, where both x and n are positive integers. Assume the input n will always be the factorial of a positive integer, so something like n=23 will not be given as ...
41
votes
17answers
4k views

Look, up in the sky! It's a super duper array!

Inspired by this question from our rivals friends over at Code Review. Definitions A super array is an array where each new element in the array is larger than the sum of all the previous elements. <...
34
votes
51answers
5k views

The first n numbers without consecutive equal binary digits

The sequence contains the decimal representation of the binary numbers of the form: 10101..., where the n-th term has n bits. The sequence is probably easiest to ...
17
votes
26answers
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 ...
24
votes
25answers
2k views

Get the decimal!

Task: Your task is, when given three inputs: a numerator n a denominator d another integer, ...
18
votes
51answers
3k views

Implement the hyperfactorial

The objective Given the non-negative integer \$n\$, output the value of the hyperfactorial \$H(n)\$. You don't have to worry about outputs exceeding your language's integer limit. Background The ...
23
votes
11answers
2k views

Infinite ordinals from a well-ordering

Your task is to write a short program that represents a large (infinite) ordinal, using a well-ordering of the set of positive integers. Your program will take two different positive integers and ...
3
votes
9answers
140 views

Find the absolute minimum difference between 2 divided numbers from n [duplicate]

Input: An integer n Output: A string A * B Example 12 Possible 2 divisible numbers: ...
26
votes
8answers
6k views

Convert infix expressions to postfix notation

When I saw the title of this closed question, I thought it looked like an interesting code golf challenge. So let me present it as such: Challenge: Write a program, expression or subroutine which, ...
11
votes
6answers
305 views

AoCG2021 Day 22: Hyperbolic rescue

Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2017 Day 11. Crossing the bridge, you've barely reached the other side of the stream when you ...
99
votes
38answers
19k views

Mandelbrot image in every language

I always used a Mandelbrot image as the 'graphical' version of Hello World in any graphical application I got my hands on. Now it's your guys' turn. Language must be capable of graphical output or ...
13
votes
12answers
1k views

Implement SKI combinator calculus

This challenge is to golf an implementation of SKI formal combinator calculus. Definition Terms S, K, and ...
47
votes
48answers
5k views

Count without 3

Background When I was in elementary school, we used to play a game in math class that goes as follows. All kids sit in a big circle and take turns counting, starting from 1. However, the following ...
43
votes
73answers
7k 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 ...
14
votes
10answers
766 views

AoCG2021 Day 14: Adjusting dancing program's period

Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2017 Day 16. I'm using the wording from my Puzzling SE puzzle based on the same AoC challenge instead of the ...
34
votes
45answers
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 ...
13
votes
12answers
1k views

Pascal's Triangle as a 2-dimensional list

Create a Pascal's Triangle that is a nested list and contains zeros in the unused spots. In the output array, the numbers of Pascal's Triangle are separated by zeroes and padded by zeroes on each ...
30
votes
4answers
1k views

Integer Complexity

Your task is to write a program that, on input n, outputs the minimal expression of each number 1 through n in order. The shortest program in bytes wins. A minimal expression combines 1's with ...
0
votes
0answers
37 views

Find the distance between 2 points in a 3d space (x,y,z) [duplicate]

Your challenge is to create the shortest code that can achieve the above problem given 6 coordinates (x1,y1,z1) (x2,y2,z2) In python 3, this can be used: (i think im correct hopefully) ...
46
votes
40answers
10k 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 ...
21
votes
19answers
2k views

Approximate the Dottie number

The Dottie number is the fixed point of the cosine function, or the solution to the equation cos(x)=x.1 Your task will be to make code that approximates this constant. Your code should represent a ...
14
votes
29answers
3k views

The inverse Collatz Conjecture

I think the Collatz Conjecture is already well-known. But what if we invert the rules? Start with an integer n >= 1. Repeat the following steps: If n is even, multiply it by 3 and add 1. If n is ...
74
votes
113answers
11k views

Collatz Conjecture (OEIS A006577)

This is the Collatz Conjecture (OEIS A006577): Start with an integer n > 1. Repeat the following steps: If n is even, divide it by 2. If n is odd, multiply it by 3 and add 1. It is proven that ...
16
votes
7answers
1k views

Define the finite field GF(9)

\$GF(9)\$ or \$GF(3^2)\$ is the smallest finite field whose order isn't a prime or a power of two. Finite fields of prime order aren't particurlarly interesting and there are already challenges for \$...
24
votes
5answers
4k views

Golf a number bigger than Loader's number

As a follow up to Shortest terminating program whose output size exceeds Graham's number and Golf a number bigger than TREE(3), I present a new challenge. Loader's number is a very large number, ...
40
votes
14answers
5k views

Shortest terminating program whose output size exceeds Graham's number

Write the shortest possible program (length measured in bytes) satisfying the following requirements: no input output is to stdout execution eventually terminates total number of output bytes exceeds ...
74
votes
175answers
15k views

Sum of all integers from 1 to n

I'm honestly surprised that this hasn't been done already. If you can find an existing thread, by all means mark this as a duplicate or let me know. Input Your input is in the form of any positive ...
81
votes
6answers
37k views

Hard code golf: Regex for divisibility by 7

Matthias Goergens has a 25,604-character (down from the original 63,993-character) regex to match numbers divisible by 7, but that includes a lot of fluff: redundant parentheses, distribution (...
44
votes
64answers
6k views

An abundance of integers!

An Abundant number is any number where the sum of its proper divisors is greater than the original number. For example, the proper divisors of 12 are: ...

1
2 3 4 5
33