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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Questions tagged [math]

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

23
votes
16answers
555 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 ...
7
votes
11answers
199 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
117 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
97 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
909 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
28answers
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
389 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. ...
19
votes
2answers
369 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
294 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
543 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
44answers
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
371 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
219 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
818 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
155 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
181 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
323 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
995 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
604 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
756 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 ...
8
votes
24answers
1k views

Golf me the Schlosberg Numbers

Schlosberg Numbers In issue 5 of Mathematical Reflections, Dorin Andrica proposed the problem of characterising the positive integers n such that is an even integer. Eight people submitted ...
-5
votes
19answers
251 views

Sum power of digits

Challenge : Given two non-negative integers (X and Y > 1) calculate the sum of digits of their powers . i.e : sum of digits of ...
10
votes
10answers
961 views

Am I a Pillai prime?

A Pillai prime is a prime number \$p\$ for which there exists some positive \$m\$ such that \$(m! + 1) \equiv 0 \:(\text{mod } p)\$ and \$p \not\equiv 1\:(\text{mod }m)\$. In other words, an ...
12
votes
25answers
2k views

Simple golfing interpreter

Challenge: Your job is to create a simple interpreter for a simple golfing language. Input: Input will be in the form of string separated by spaces. You can replace space separation with what you ...
43
votes
41answers
5k views

Detect heat waves

Background The Royal Netherlands Meteorological Institute defines a heat wave* as a series of at least 5 consecutive days of ≥25°C weather (“summery weather”), such that at least 3 of ...
5
votes
27answers
1k views

Simple Factorial Challenge [duplicate]

In light of today's date... A factorial of a number n, is the product of all the numbers from 1 to n inclusive. The Challenge Given an integer n where 0 <= n <= 420, find the sum of the ...
18
votes
13answers
2k views

Conway's Prime Game

Specifically, Conway's PRIMEGAME. This is an algorithm devised by John H. Conway to generate primes using a sequence of 14 rational numbers: ...
9
votes
44answers
3k views

Integer logarithms

Given integers N , P > 1 , find the largest integer M such that P ^ M ≤ N. I/O: Input ...
11
votes
3answers
408 views

Polynomial -> Integrate

Given a polynomial in one variable with rational coefficients, output an equivalent expression containing only 1, variables, and definite integrals. For example, -...
5
votes
17answers
803 views

Solve for N from input string

Challenge : Your job is to find the given number N. Input : You will be given a string in the following form: dN ± Y = X ...
17
votes
26answers
1k views

Rotational Average

Given an input integer n >= 10, output the average of all deduplicated rotations of the integer. For example, for input 123, ...
13
votes
12answers
714 views

Circle intersection area

Description : Given x and y positions of two circles along with their radii, output the ...
3
votes
2answers
67 views

Generate lowest degree polynomial from sequence [duplicate]

Introduction A sequence of numbers is passed in as the input. The program has to generate the lowest degree polynomial possible. This was my first programming project in college and it would be ...
22
votes
17answers
1k views

Generate a Walsh Matrix

A Walsh matrix is a special kind of square matrix with applications in quantum computing (and probably elsewhere, but I only care about quantum computing). Properties of Walsh matrices The ...
-6
votes
20answers
528 views

XOR reduction bools

Description : Given a string of space separated binary digits or space separated booleans or an array of binary digits or array of booleans . Your job is to find the xor of each until you end up with ...