Questions tagged [math]

The challenge involves mathematics. Also consider using more specific tags: [number] [number-theory] [arithmetic] [combinatorics] [graph-theory] [geometry] [abstract-algebra] [integer].

Filter by
Sorted by
Tagged with
-7
votes
0answers
51 views

Increment a number [duplicate]

Input One integer. The integer can be given in the natural format of your language of choice. It can from standard input, as an argument to the program of function, or wrapped in a list. Output The ...
15
votes
24answers
1k views

Semidivisibility

NOTE: Some terminology used in this challenge is fake. For two integers n and k both greater than or equal to 2 with ...
21
votes
26answers
2k views

Reconstruct an integer from its prime exponents

All integers \$n > 0\$ can be expressed in the form $$n = \prod_{\text{prime } p} p^e = 2^{e_2} 3^{e_3} 5^{e_5} 7^{e_7} \cdots$$ This form is also known as it's prime factorisation or prime ...
5
votes
17answers
221 views

Which th second now in this year

In this challenge you have to find out which nth second it is now in this year, current date and time now. Or in other words, how many seconds have passed since New Year. An example current Date is (...
28
votes
24answers
2k views

First sequence with no square differences

Consider the sequence \$(a_n)\$ defined in the following way. \$a_0=0\$ For all \$n=1, 2, 3, \dots\$, define \$a_n\$ to be the smallest positive integer such that \$a_n-a_i\$ is not a square number, ...
15
votes
15answers
1k views

Generalise perfect numbers

Let \$\sigma(n)\$ represent the divisor sum of \$n\$ and \$\sigma^m(n)\$ represent the repeated application of the divisor function \$m\$ times. Perfect numbers are numbers whose divisor sum equals ...
17
votes
7answers
946 views

Square root multiples

This code-challenge is based on OEIS sequence A261865. \$A261865(n)\$ is the least integer \$k\$ such that some multiple of \$\sqrt{k}\$ is in the interval \$(n,n+1)\$. The goal of this challenge is ...
17
votes
18answers
2k views

Determine the degree of a polynomial

Background: For this challenge, a polynomial looks like this: $$P(x)=a_nx^n+a_{n-1}x^{n-1}+\dots+a_2x^2+a_1x+a_0$$ The degree, \$n\$, is the highest power \$x\$ is raised to. An example of a degree 7 ...
18
votes
11answers
2k views

What's next, Achilles?

Powerful numbers are positive integers such that, when expressed as a prime factorisation: $$a = p_1^{e_1} \times p_2^{e_2} \times p_3^{e_3} \cdots \times p_k^{e_k}$$ all exponents \$e_1, e_2, ...\$ ...
17
votes
5answers
890 views

Count all binary relations

A binary relation on a set \$X\$ is simply a subset \$S \subseteq X \times X\$; in other words, a relation is a collection of pairs \$(x,y)\$ such that both \$x\$ and \$y\$ are in \$X\$. The number of ...
2
votes
0answers
163 views

Compute the Three Dimensional Discrete Cosine Transform

Challenge I've checked that there is a question Compute the Discrete Cosine Transform which is a competition for implementing a shortest solution to compute the one dimensional discrete cosine ...
11
votes
14answers
1k views

Verify the inequality!

Left in sandbox for at least 3 days. I want to verify if this inequality is true: for \$n\geq4\$, if \$a_1,a_2,a_3,\dots,a_n\in R_+\cup\{0\}\$ and \$\sum_{i=1}^na_i=1\$, then \$a_1a_2+a_2a_3+a_3a_4+\...
11
votes
11answers
825 views

Definite integral of polynomial functions

You will need to evaluate the definite integral (bounded by \$a\$ and \$b\$) of a certain polynomial function that takes the form of: $$\int_a^b \left( k_n x^n + k_{n-1} x^{n-1} + \cdots + k_2x^2 + ...
16
votes
2answers
393 views

Count unrooted, unlabeled binary trees of n nodes

An unrooted binary tree is an unrooted tree (a graph that has single connected component and contains no cycles) where each vertex has exactly one or three neighbors. It is used in bioinformatics to ...
2
votes
0answers
206 views

How long to paint this house? [closed]

Here is the problem, for which I can only think of an iterative solution and have not found a closed formula: You need to paint a house with R rooms. For each room there are four walls and one ...
17
votes
13answers
3k views

Landau logarithm

Related: Landau's function (OEIS A000793) Background Landau's function \$g(n)\$ is defined as the largest order of permutation of \$n\$ elements, which is equal to \$\max(\operatorname{lcm}(a_1,a_2,\...
3
votes
0answers
343 views

Solve a Cubic Equation [closed]

Input Your program will take in the integer coefficients of the equation \$ax^3+bx^2+cx+d=0\$ as inputs (a, b, c, and d). Output All real solutions of the input equation, with an accuracy of at ...
13
votes
20answers
2k views

Linear integer function generator

Inspired by a recent challenge involving Fibonacci numbers in which OEIS was mentioned, I would like to present a challenge of creating a function that generates a wide array of different linear ...
22
votes
18answers
999 views

Interpret Interval Notation

Interval notation is a way to write complicated range bounds more conveniently and concisely than writing an inequality. The challenge, should you choose to accept it, is to write a program or ...
12
votes
5answers
579 views

Ellipsoid surface area

Related: Ellipse circumference Introduction An ellipsoid (Wikipedia / MathWorld) is a 3D object analogous to an ellipse on 2D. Its shape is defined by three principal semi-axes \$a,b,c\$: $$ \frac{x^2}...
12
votes
24answers
968 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, \$...
19
votes
27answers
997 views

Partial sums of the Kempner series

The Kempner series is a series that sums the inverse of all positive integers that don't contain a "9" in their base-10 representations (i.e., \$\frac{1}{1} + \frac{1}{2} + \frac{1}{3} + .. +...
29
votes
2answers
1k views

Golf the smallest sphere!

Inspired by this challenge, as well as a problem I've been working on Problem: Given a non-empty set of points in 3D space, find the diameter of the smallest sphere ...
12
votes
7answers
624 views

Generalised Taxicab Numbers

\$\newcommand{T}[1]{\text{Ta}(#1)} \newcommand{Ta}[3]{\text{Ta}_{#2}^{#3}(#1)} \T n\$ is a function which returns the smallest positive integer which can be expressed as the sum of 2 positive integer ...
22
votes
2answers
1k views

Eye test - How many squares are in this picture?

The picture: Sick of the same old grid where the answer is simply a square pyramidal number? Accept the challenge and write a program that given a positive integer \$n\$ counts how many squares are ...
11
votes
18answers
1k views

Polynomial Laplace transform

This is a repost of this challenge, intended to revamp it for looser I/O formats and updated rules You are to write a program which takes an integer polynomial in \$t\$ as input and outputs the ...
15
votes
4answers
915 views

(Almost) Solve Fermat's Last Theorem

It's a well-known fact that Fermat's Last Theorem is true. More specifically, that for any integer \$n \gt 2\$, there are no three integers \$a, b, c\$ such that $$a^n + b^n = c^n$$ However, there are ...
22
votes
27answers
2k views

“Factorise” a quadratic

When learning to factorise quadratics in the form \$x^2 + ax + b\$, a common technique is to find two numbers, \$p, q\$ such that $$pq = b \\ p + q = a$$ as, for such numbers, \$x^2 + ax + b = (x + p)(...
20
votes
19answers
2k views

For what block sizes is this checksum valid?

The input: As an example, take a list containing a number of bits (in this case, 32): 11000010000100111011000011001011 We can calculate a simple checksum of this ...
20
votes
27answers
2k views

Perfect radicals

Given a positive integer number \$n\$ output its perfect radical. Definition A perfect radical \$r\$ of a positive integer \$n\$ is the lowest integer root of \$n\$ of any index \$i\$: $$r = \sqrt[i]{...
34
votes
63answers
5k views

Infinitely many ℕ

Background: A sequence of infinite naturals is a sequence that contains every natural number infinitely many times. To clarify, every number must be printed multiple times! The Challenge: Output a ...
17
votes
20answers
2k views

Find distance between the closest 3D points

Your task is to take \$n \ge 2\$ points in 3D space, represented as 3 floating point values, and output the Euclidean distance between the two closest points. For example $$A = (0, 0, 0) \\ B = (1, 1, ...
17
votes
13answers
1k views

All-inclusive semi-primes

\$723 = 3 \times 241\$ is a semi-prime (the product of two primes) whose prime factors include all digits from \$1\$ to \$n\$, where \$n\$ is the total number of digits between them. Another way to ...
2
votes
0answers
116 views

Dobble Double Challenge [closed]

I have a problem, which I haven't found a solution for. Solutions to the first part are well documented, but I have yet to find anyone who has solved the second part. I call this the "Dobble"...
10
votes
7answers
2k views

Fastest square root of an arbitrary size

We do seem to have a fastest square root challenge, but it's very restrictive. In this challenge, your program (or function) will be given an arbitrarily sized nonnegative integer, which is the square ...
33
votes
23answers
3k views

Narcissistic loop lengths

A narcissistic number is a natural number which is equal to the sum of its digits when each digit is taken to the power of the number digits. For example \$8208 = 8^4 + 2^4 + 0^4 + 8^4\$, so is ...
22
votes
36answers
2k views

Display the exponent from a binary floating point number as a decimal value

Had my software final exams recently, one of the last questions had me thinking for a while after the exam had finished. Background IEEE754 numbers are according to the below layout The exponent is ...
14
votes
1answer
402 views

Total resistance from unit resistors

This problem is based on, A337517, the most recent OEIS sequence with the keyword "nice". \$a(n)\$ is the number of distinct resistances that can be produced from a circuit with exactly \$n\...
14
votes
14answers
470 views

Repetend length in 1/n

This problem is based on non-terminating, repeating decimal points. Let \$n\$ be any positive integer \$(n > 1 \text{ and } n < 10000)\$, say \$7\$. Then, \$1/n = 1/7 = 0.142857142857142857...\$ ...
9
votes
14answers
372 views

Golf a bijection \$\mathbb{N}^n\to\mathbb{N}\$

Your task is to write a program which implements a bijection \$\mathbb{N}^n\to\mathbb{N}\$ for \$n \ge 1\$. Your program should take \$n\$ natural numbers as input, in any acceptable method (including ...
24
votes
9answers
3k views

The square root of the square root of the square root of the…

This code-golf challenge will give you an integer n, and ask you to count the number of positive integer sequences \$S = (a_1, a_2, \dots, a_t)\$ such that \$a_1 + ...
22
votes
17answers
2k views

A Portuguese sequence of integers

Context Consider the following sequence of integers: $$2, 10, 12, 16, 17, 18, 19, ...$$ Can you guess the next term? Well, it is \$200\$. What about the next? It is \$201\$... In case it hasn't become ...
18
votes
13answers
1k views

Find all integer pairs that produce a given Loeschian number

Inspired by and drawns from Is this number Loeschian? A positive integer \$k\$ is a Loeschian number if \$k\$ can be expressed as \$i^2 + j^2 + i\times j\$ for \$i\$, \$j\$ integers. For example, ...
37
votes
17answers
2k views

Three other numbers

Given three distinct numbers from \$1\$ to \$7\$, output three other distinct numbers from \$1\$ to \$7\$, that is having no numbers in common with the original numbers. Your code must produce a ...
20
votes
37answers
4k views

Is that number a Two Bit Number™️?

Let's start by defining a Two Bit Number™️: It is a positive integer When expressed as a binary string it has exactly 2 true bits OR When expressed as a decimal number, it has exactly 2 of the ...
30
votes
24answers
3k views

Circumference of an ellipse

Challenge Unlike the circumference of a circle (which is as simple as \$2\pi r\$), the circumference of an ellipse is hard. Given the semi-major axis \$a\$ and semi-minor axis \$b\$ of an ellipse (see ...
13
votes
17answers
1k views

Plot a centered circle

Intro Given radius \$r\$, draw a circle in the center of the screen. Sandbox. The Challenge Here is a simple challenge. Plot a circle using the formula \$x^2+y^2=r^2\$, or any other formula that will ...
22
votes
16answers
2k views

Delicate primes

Inspired by Find the largest fragile prime. By removing at least 1 digit from a positive integer, we can get a different non-negative integer. Note that this is different to the ...
-2
votes
1answer
133 views

The Perfect Polynomial [closed]

The coefficients of a perfect square polynomial can be calculated by the formula \$(ax)^2 + 2abx + b^2\$, where both a and b are integers. The objective of this challenge is to create a program that ...
16
votes
27answers
477 views

\$n\$-perfect numbers

A positive integer \$x\$ is an \$n\$-perfect number if \$\sigma(x) = nx\$, where \$\sigma(x)\$ is the divisor sum function. For example, \$120\$ is a \$3\$-perfect number because its divisors sum to \$...

1
2 3 4 5
30