Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [math]

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

7
votes
5answers
246 views

Multiply numerical polynomials

A numerical polynomial is a polynomial \$p\$ in one variable with rational coefficients such that for every integer \$i\$, \$p(i)\$ is also an integer. The numerical polynomials have a basis given by ...
-1
votes
0answers
66 views

1000^3 space, 10 bombs and a spaceship [on hold]

Some time ago I had a coding test, kind of riddle: there is 3D space 1000x1000x1000 (each 1-1000, integer), 10 bombs are randomly located in this space, place one spaceship as far as possible from ...
8
votes
0answers
115 views

Find a way to determine to which fibonacci squares a given coordinate belongs [closed]

Given a random coordinate (x,y), determine in which square (squares are referenced by their sidelength) it is (or the borders of which squares). The squares are drawn in a counter clockwise direction,...
-3
votes
5answers
68 views

Concatenate 2 numeric type values to a fixed size number [closed]

You have 2 numbers, both stored separate as numeric data type. First number is always 6 digits long. Second number can vary between 1 and 4 digits. If it's less than 4 digits, it needs to be padded ...
18
votes
12answers
2k views

Is the Matrix Positive-Definite?

Introduction Today we're gonna take care of the bane of first-year linear algebra students: matrix definiteness! Apparently this doesn't yet have a challenge so here we go: Input A \$n\times n\$ ...
4
votes
3answers
177 views

Hyperoperation Golfing [duplicate]

Introduction In mathematics, the hyperoperation sequence is an infinite sequence of arithmetic operations (called hyperoperations) that starts with the unary operation of successor (n = 0), then ...
5
votes
0answers
256 views

What is the simplest reversible circuit that computes conjugacy of transpositions?

Reversible computation refers to computation in which little or no information is deleted. Reversible computation a major component of quantum computation, and reversible computation is potentially ...
8
votes
8answers
215 views

Cayley Table of the Dihedral Group \$D_3\$

The Dihedral group \$D_3\$ represents the symmetries of an equilateral triangle, using the identity (represented by id), rotations (represented by ...
16
votes
38answers
1k views

Sum \$\text{Square}^2\$

Let \$n=42\$ (Input) Then divisors are : 1, 2, 3, 6, 7, 14, 21, 42 Squaring each divisor : 1, 4, 9, 36, 49, 196, 441, 1764 Taking sum (adding) : 2500 Since \$50\times 50=2500\$ therefore we return ...
0
votes
0answers
126 views

Make n n n n = x [duplicate]

Background So I've been inspired by this puzzleing SE question to create a similar Code Golf challenge. The basic puzzle format is you must use 4 numbers, such as 5 5 5 5, to equal some other number, ...
6
votes
20answers
389 views

Find the \$\left(n^2\right)^\text{th }n\$-gonal number

Given a non-negative integer, \$n\$, yield the \$(n^2)^\text{th } n\$-gonal number. Further Detail: The \$x\$-gonal numbers, or polygonal numbers, are also known as the two-dimensional figurate ...
20
votes
17answers
3k views

How many cubes can be built

task Your task is to build a structure with \$n\$ cubes. The volume of cubes follow the following sequence (bottom -> top) \$n^3, (n-1)^3, (n-2)^3,...,1^3\$ input The total volume of the ...
24
votes
14answers
1k views

Number Spiral Problem

A number spiral is an infinite grid whose upper-left square has number 1. Here are the first five layers of the spiral: Your task is to find out the number in row y and column x. Example: ...
12
votes
17answers
465 views

Compute the minimum \$a(n)>a(n-1)\$ such that \$a(1)+a(2)+\dots+a(n)\$ is prime (OEIS A051935)

Background Consider the following sequence (A051935 in OEIS): Start with the term \$2\$. Find the lowest integer \$n\$ greater than \$2\$ such that \$2+n\$ is prime. Find the lowest integer \$n'\$ ...
17
votes
22answers
2k views

Sort by what the digit pairs describe

Given a positive integer, we can form a new number that's described by its digits taken pairwise (with a leading 0 added for numbers with odd number of digits). For eg.: 1234 can be read as one 2, ...
29
votes
18answers
1k views

Custom Number Base Converter

The powers that be want to be able to quickly convert any number they have into their own number base using any format they would like. Input Your program must accept 3 parameters. Number: The ...
8
votes
12answers
291 views

Construct a line graph / conjugate graph

Introduction Given an undirected graph G, we can construct a graph L(G) (called the line graph or conjugate graph) that represents the connections between edges in G. This is done by creating a new ...
21
votes
17answers
1k views

RTA (Reverse-Then-Add) root of a number

The reverse-then-add (RTA) sequence is a sequence obtained by adding a number to its reverse, and repeating the process on the result. For eg., $$ 5 + 5 = 10 \Rightarrow 10 + 01 = 11 \Rightarrow 11 +...
-3
votes
1answer
124 views

number decomposition [duplicate]

It's been a while since I posted here, so here we go another day another challenge. Challenge : Given a number(n) split it into it's prime factors. Input : A ...
0
votes
1answer
107 views

Symmetric Numbers [duplicate]

write a function to tell if a number is symmetric or not. for example: input: 151 output: True input: 142 output: False and so on: 1111 True, 2390 False, 1226221 True
17
votes
34answers
943 views

Calculate power series result [duplicate]

Related: Calculate Power Series Coefficients Given a positive integer \$X\$ and a max exponent (Also a positive integer too) \$N\$ calculate the result of a power series. Example: $$X^0+X^1+X^2+\...
18
votes
29answers
2k views

Count the lucky tickets within the given range

In Russia we have something like a tradition: we like to look for lucky tickets. Here's what a regular ticket looks like: As you can see, the ticket has a six-digit number. A six-digit number is ...
22
votes
16answers
3k views

Find the inverse of a 3 by 3 matrix

Challenge Given nine numbers, a, b, c, d, e, f, g, h, i, as input which correspond to the square matrix: $$\mathbf{M} = \begin{pmatrix}a& b& c\\ d& e&...
14
votes
14answers
1k views

Exact Partial Sum of Harmonic Series

Challenge Given a positive integer N, output the sum of the first N reciprocals as an exact fraction, which is represented as a ...
6
votes
11answers
435 views

Draw a times table (also called modular multiplication circle) of a number \$n\$ with \$k\$ vertices

Not to be confused with this question. You need to draw a times table (also known as Cremona's method for cardioid generation) as shown in this video. The number \$n\$ and \$k\$ will be the inputs. ...
20
votes
2answers
404 views

Existential Golf

Math has a lot of symbols. Some might say too many symbols. So lets do some math with pictures. Lets have a paper, which we will draw on. To start the paper is empty, we will say that is ...
-6
votes
15answers
310 views

Perfect Squares below \$n\$

A perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself. Calculate the number of perfect squares below a number \$n\$ where \$...
11
votes
39answers
4k views

Last digit large number

For a given list of number \$[x_1, x_2, x_3, ..., x_n]\$ find the last digit of \$x_1 ^{x_2 ^ {x_3 ^ {\dots ^ {x_n}}}}\$ Example: ...
21
votes
2answers
554 views

Double a number's continued fraction

Your task is, given x, output 2*x. Easy right!? But there's a catch: x will be given as a (...
19
votes
34answers
2k views

Find the Squarish Root

Write code that when given a positive number \$x\$ as input, outputs the largest positive divisor of \$x\$ less than or equal to the square root of \$x\$. In other words find the largest \$n > 0\$ ...
24
votes
17answers
2k views

Integers sorted by their digital roots

The digital root (also repeated digital sum) of a positive integer is the (single digit) value obtained by an iterative process of summing digits, on each iteration using the result from the previous ...
19
votes
45answers
2k views

count ones in range

Challenge : Count the number of ones 1 in the binary representation of all number between a range. Input : Two non-decimal positive integers Output : The sum ...
2
votes
2answers
383 views

Which number is bigger?

Define f(a,b) := a if b=1; a^f(a,b-1) if b>1 (Tetration, where ^ means power) for positive integers ...
18
votes
19answers
2k views

Evaluate polynomial expression string

Create a function which takes a polynomial equation, a value for x and returns the result of the operation. Example: given ...
-1
votes
11answers
228 views

Smallest possible version of abs [duplicate]

The abs() function in most languages does one thing: give the positive version of the input. Most of the times this is done using something similar to ...
10
votes
22answers
1k views

Cartesian product of a list with itself n times

When given a a list of values and a positive integer n, your code should output the cartesian product of the list with itself n ...
11
votes
12answers
820 views

Sum of replicated matrices

Given a list of numbers [ a1 a2 ... an ], compute the sum of all the matrices Aᵢ where Aᵢ is defined as follows (m is the maximum of all aᵢ): ...
3
votes
0answers
182 views

Mathematical parser [duplicate]

Challenge : Given a string representing a mathematical expression return the result Input : A string representing a mathematical expression : ...
3
votes
0answers
159 views

Make Three from One [duplicate]

Given a single digit integer and a three digit integer, output a mathematical formula that uses only the single digit and a given list of operators to equal the three digit integer. Input: A one ...
-1
votes
1answer
186 views

Find the longest uninterrupted arc in N dimensions

See similar question for 2D case: Find the longest uninterrupted arc The challenge here is to find the longest uninterruped great circle arc around a unit hypersphere in N dimensions, with a random ...
5
votes
3answers
326 views

Find the longest uninterrupted arc

The challenge here is to find the longest uninterruped arc around a unit circle with a random amount of points distributed in random positions around it. Here is a diagram to assist my explanation: ...
20
votes
5answers
1k views

Golfing out the haters

The setup: A social network reports the number of votes a post has in two ways: the number of net upvotes (total upvotes - total downvotes), and the % of votes that were upvotes, rounded to the ...
24
votes
34answers
2k views

Sign-Swapping Sums

Given a nonempty list of positive integers \$(x, y, z, \dots)\$, your job is to determine the number of unique values of \$\pm x \pm y \pm z \pm \dots\$ For example, consider the list \$(1, 2, 2)\$. ...
16
votes
7answers
1k views

Nim Multiplication

Background If you do much code golfing, you're likely aware of the bitwise XOR operation. Given two integers, it gives another integer with 1s in the bits where ...
51
votes
11answers
3k views

Bringing a pair of integers to equality

This was inspired by a math problem I saw somewhere on the internet but do not remember where (UPDATE: The original problem was found on the math riddles subreddit with a proof provided that it is ...
36
votes
1answer
606 views

What's in my pasta sauce?

Background In France, and probably in the rest of the European Union, any food available for sale must list the ingredients that compose it on its packaging, in weight percentage descending order. ...
14
votes
25answers
2k views

Prime or highest factor

Challenge: Given an array of non-negative whole numbers numbers in the range of 0 to Infinity, Check whether all of them are primes or not. (You can take input as ...
16
votes
21answers
2k views

Is this a staircase number?

Challenge : Check if the given number forms a number staircase or not Input : A integer (greater than 0 and not decimal). NOTE : You can take input as string , ...
-4
votes
53answers
763 views

Return the highest possible placement value based on the input

Introduction The challenge itself was something I came across and had to try and figure out for a personal of project of mine. I ended up branching out and asking family members if they could provide ...
29
votes
12answers
1k views

Triangular Lattice Points close to the Origin

Background A triangular grid is a grid formed by tiling the plane regularly with equilateral triangles of side length 1. The picture below is an example of a triangular grid. A triangular lattice ...