Questions tagged [math]
The challenge involves mathematics in some central way. Also consider using more specific tags, listed in the tag wiki info.
1,771
questions
16
votes
16
answers
4k
views
Which skill to train?
Story (skip, if you prefer the naked task): You need five skills for an imaginary sport: Speed, strength, endurance, accuracy and tactics. If you achieve a score in each of these disciplines, you can ...
4
votes
1
answer
184
views
Convert real numbers between factoradic and positive integer bases
This prompt asked you to convert back and forth to factoradic, but is very limited in scope (only decimal integers from 0 to 10!-1). Your task in this challenge is to reach just a bit further and ...
1
vote
0
answers
130
views
Produce a secure block cipher round function (1 bit round key; 7 bit message)
We need to produce a block cipher round function with a 1 bit round key size and a 7 bit message size with the highest level of cryptographic security according to our measure of security.
...
9
votes
8
answers
659
views
Produce the shortest suffix for an (almost) arbitrary string
I encountered some silly code from a game and I figured this would actually turn into a fun golfing problem, so:
Given any ASCII string in the limited char range specified below.
Append as few ...
12
votes
6
answers
2k
views
Sine using square root [closed]
Given input \$x \in \left\{0,3,6,...,90\right\}\$, output \$\sin\left(x°\right)\$ using integer and \$+ - \times \div ( ) \sqrt{\cdot}\$(square root), e.g. \$\sin(45°)=\sqrt{1\div 2}\$.
Flexible ...
17
votes
14
answers
2k
views
Finding the power sandwich version 2
Introduction
This question is inspired by this great question.
Challenge
Given a number \$N>0\$, output the largest integer \$a^b\$ that is smaller or equal to \$N\$, and the smallest integer \$c^d\...
15
votes
16
answers
2k
views
Finding the power sandwich
Introduction
Finding the closest power to a number is a common enough problem. But what if you need both the next-highest and next-lowest power? In this challenge you must find the closest powers to a ...
10
votes
6
answers
361
views
Hermite interpolation
We already have a challenge for polynomial interpolation: given a list of points, output the coefficients of the polynomial that passes through them.
Hermite interpolation is a generalization of ...
13
votes
10
answers
1k
views
Expected number of rounds for this labeling scheme
Task
Here is an interesting math problem:
Let's say that there are \$n\$ indistinguishable unlabeled objects in a bin. For every "round", pull \$k\$ objects randomly out of the bin with ...
9
votes
5
answers
452
views
Write a variadic fixed point combinator
A fixed-point combinator is a higher order function \$\mathrm{fix}\$ that returns the fixed point of its argument function. If the function \$f\$ has one or more fixed points, then $$\mathrm{fix} f=f(\...
3
votes
2
answers
251
views
Visualise the Euclidean GCD [duplicate]
The Euclidean GCD Algorithm is an algorithm that efficiently computes the GCD of two positive integers, by repeatedly subtracting the smaller number from the larger number until they become equal. It ...
15
votes
18
answers
2k
views
Divisor chain counts (1 3 3 7 ...)
The divisors of a natural number form a poset under the relation of "a divides b?", \$a | b\$. This challenge is to produce the number, \$C\$, of non-empty chains of such posets for natural ...
9
votes
5
answers
1k
views
Random factorized numbers
Input
The code should take an integer \$n\$ between 1 and 1000.
Output
The code should output positive integers with \$n\$ bits. Accompanying each integer should be its full factorization. Each ...
9
votes
9
answers
2k
views
Make a super fair number
An even distribution number is a number such that if you select any of it's digits at random the probability of it being any particular value (e.g. 0 or ...
22
votes
8
answers
1k
views
Write a set as a union of ranges
In this challenge, we define a range similarly to Python's range function: A list of positive integers with equal differences between them. For example, ...
13
votes
11
answers
5k
views
Print 100 digits of π
Your challenge is to print any 100 consecutive digits of π. You must give the index at which that subsequence appears. The 3 is not included.
For example, you could print any of the following:
...
10
votes
7
answers
729
views
Longest sequence of Egyptian fractions with n as denominator
Background
From Wikipedia: An Egyptian fraction is the sum of distinct unit fractions. That is, each fraction in the expression has a numerator equal to 1 and a denominator that is a positive integer, ...
9
votes
12
answers
3k
views
Funny Numbers :D
The task is to calculate the average "funniness" of a given number given the following scoring system:
1 point for each "420" in it
2 points for each "69" in it
3 points ...
6
votes
4
answers
469
views
Sums of Euler's totient function in sublinear time
Related.
Given a number \$n\$, Euler's totient function, \$\varphi(n)\$ is the number of integers up to \$n\$ which are coprime to \$n\$. That is, no number bigger than \$1\$ divides both of them.
For ...
11
votes
26
answers
2k
views
Find the smallest integer multiple of a Decimal
The Challenge
Given a rational number, determine the smallest number which is a positive integer multiple of it. Eg.
...
24
votes
23
answers
4k
views
American odds to probabilities
American odds (aka moneyline odds) are numbers like \$+150\$ or \$-400\$ used to express how much a winning bet would pay out. Convert odds to a fair win probability like this:
Positive odds \$+n\$ ...
16
votes
6
answers
2k
views
What's my score?
The question score on Stack Exchange is the total number of upvotes minus the total number of downvotes a question receives. However, the reputation gained/lost for every upvote/downvote is different (...
23
votes
10
answers
2k
views
How many ways to cut a number into an equation?
Too bad! I had such a beautiful equation, but I lost all my =+-*, so there is nothing left but a chain of digits, looking like a number: ...
20
votes
11
answers
1k
views
Sums of sum of divisors in sublinear time
Given a number \$n\$, we have its sum of divisors, \$\sigma(n)\ = \sum_{d | n} {d}\$, that is, the sum of all numbers which divide \$n\$ (including \$1\$ and \$n\$). For example, \$\sigma(28) = 1 + 2 +...
10
votes
13
answers
2k
views
Decimalize a Fraction
Preamble
A common pain-point when working with rational numbers and decimals is how infrequently one can represent their rational number as a clean, non-repeating decimal. Let's solve this by writing ...
23
votes
14
answers
2k
views
Sum of consecutive nth powers
Related.
Given a positive integer \$n\$, output all integers \$b\$ (such that \$1<b<n-1\$) where \$n\$ can be written as the sum of any number of consecutive powers of \$b\$.
Example:
Let's say \...
11
votes
20
answers
4k
views
Add two really big numbers
Preamble
We've already proven we're good at adding two numbers, but many solutions only operate on tiny numbers like 2³²-1, honestly we can do a lot better.
The Challenge
Given two unsigned, non-...
10
votes
6
answers
952
views
Calculate the Distance to a Line Segment
The Challenge
Given two vertexes and a point calculate the distance to the line segment defined by those points.
This can be calculated with the following psudocode
...
12
votes
4
answers
437
views
Zeckendorf to F(4k+2) representation
Background
Fibonacci numbers are defined as follows:
$$
F_0 = 0, F_1 = 1, F_n = F_{n-1} + F_{n-2}
$$
The Zeckendorf representation is a representation of positive integers as a sum of one or more non-...
20
votes
9
answers
2k
views
Cutting a Circular Pizza Vertically
Most people would cut circular pizzas into circular sectors to divide them up evenly, but it's also possible to divide them evenly by cutting them vertically like so, where each piece has the same ...
16
votes
15
answers
1k
views
Find separating sets
Two points pand q in a topological space can be separated if there are open sets U and ...
21
votes
18
answers
2k
views
Is this set laminar?
A family of sets is called laminar if for any two sets \$A\$ and \$B\$ in the family one of the following is true:
\$ A \subseteq B \$
\$ A \supseteq B \$
\$ A \cap B = \emptyset \$
Or less ...
9
votes
5
answers
797
views
Compute the logarithm of a matrix
There have already been challenges about computing the exponential of a matrix , as well as computing the natural logarithm
of a number. This challenge is about finding the (natural) logarithm of ...
15
votes
7
answers
1k
views
Solve quadratic equations when 1+1=0
There already have been multiple challenges about carryless
multiplication, this challenge will work with the same calculation rules.
You task is given a quadratic polynomial ...
17
votes
22
answers
2k
views
Compute this fractal matrix
The unique-disjointness matrix ( UDISJ(n) ) is a matrix on all pairs of subsets of {1...,n} with entries $$ U_{(A,B)}=\begin{cases}
0, ~ if ~ |A\cap B|=1\\
1, ~ ...
14
votes
14
answers
2k
views
Print all Polynomials
The set of all polynomials with integer coefficients is countable.
This means that there is a sequence that contains each polynomial with integer coefficients exactly once.
Your goal is it to write a ...
11
votes
22
answers
2k
views
Generate the Crystal Maze™ time matrix
Behold! The Crystal Maze™ Time Matrix!
...
19
votes
10
answers
3k
views
Numbers that can be negated by reading backwards
Balanced ternary is a modified version of ternary (base 3), using the three digits 1,0 and -1...
24
votes
38
answers
2k
views
Diagonalize a vector
Diagonalize a vector into a matrix.
Input
A vector, list, array, etc. of integers \$\mathbf{v}\$ of length \$n\$.
Output
A \$n \times n\$ matrix, 2D array, etc. \$A\$ such that for each element \$a_i \...
0
votes
1
answer
74
views
Find the sum of primes [duplicate]
Given a number x, find the sum of all primes up to that number.
The input will always be a positive number, bigger than 2. An upper limit isn't defined, so data types can be ignored. Use whichever you ...
14
votes
19
answers
3k
views
Vanilla Natural Logarithm Challenge
There is a challenge for multiplying two numbers so I guess this counts too
Given as input a positive real number n compute its natural logarithm.
Your answer ...
22
votes
40
answers
3k
views
Sum of a range of a sum of a range of a sum of a range of a sum of a range of a sum of
Inspired by the fact that a few related challenges to this could be answered by Vyxal in 0 Bytes using a special flag combination.
Given only one input integer \$n\$, calculate \$f(n,n)\$ where
$$ f(x,...
17
votes
18
answers
2k
views
XOR of independent Bernoulli variables
In probability theory, a Bernoulli variable is a random variable which has a single parameter \$p\$, and is equal to 1 with probability \$p\$, and 0 with probability \$1-p\$.
In this challenge, there ...
47
votes
38
answers
3k
views
Last odd digit of power of 2
Task
Given \$n\$, output position of the last odd digit in the decimal representation of \$2^n\$ (counting from the end).
Rules
There are no odd digits for \$n=1,2,3,6,11\$ \$(2, 4, 8, 64, 2048)\$ - ...
10
votes
40
answers
2k
views
Output endless powers of 2 [duplicate]
In any programming language, make a program that outputs infinite subsequent powers of two, starting at any power of two with finite integer exponent. There does not need to be a seperator between ...
19
votes
19
answers
2k
views
Logarithmic Incrementation
In this challenge you will write a function that takes a list (ordered set) containing real numbers (the empty list is an exception, as it has nothing) and calculates
$$f(x)=\begin{cases}1 & \text{...
21
votes
7
answers
1k
views
How many sorting networks?
Below on the left is a picture of a sorting network that can sort 4 inputs. On the right you can see it sorting the input 3,2,4,1.
A sorting network of size ...
14
votes
13
answers
1k
views
Resultant of two polynomials
The resultant of two polynomials is a polynomial in their coefficients that is zero if and only if \$p\$ and \$q\$ have a common root. It is a useful tool for eliminating variables from systems of ...
14
votes
8
answers
1k
views
Euclidean distance on projective plane
Motivated by this challenge
Background
Let we have a square sheet of flexible material.
Roughly speaking, we may close it on itself four ways:
Here the color marks the edges that connect and the ...
22
votes
11
answers
3k
views
How powerful must this e approximation be?
This challenge was inspired by this non-challenge about the natural logarithm base \$e\$ and the following pandigital approximation to \$e\$ appearing on a Math Magic page:
$$\left|(1+9^{-4^{7×6}})^{3^...