Stack Exchange Network

Stack Exchange network consists of 175 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].

16
votes
19answers
3k views

Hermitian matrix?

Note that this challenge requires no handling or understanding of complex numbers. Given a non-empty square matrix where every element is a two-element (Re,Im) integer list, determine (giving any ...
31
votes
10answers
1k views

Find the dot product of Rationals

I was at a friend's house for dinner and they suggested the idea of a "Prime-factor vector space". In this space the positive integers are expressed as a vector such that the nth element in the ...
10
votes
4answers
287 views

Continued Fraction of Digit-wise Sum of Square Roots

Introduction Your task is to generate the first 1000 terms in the continued fraction representation of digit-wise sum of square root of 2 and square root of 3. In other words, produce exactly the ...
21
votes
2answers
1k views

Integer Linear Programming

Introduction Write a solver for integer linear programming. Challenge Your task is write a solver for integer linear programming (ILP). In ILP, linear inequalities of a set of unknowns (all of ...
-6
votes
45answers
880 views

Quartic Summation

Guidelines Task Given two non-negative integers, find the sum of both numbers... to the power of 4. Examples 2, 3 -> 97 (2^4 + 3^4 = 97) ...
0
votes
0answers
49 views

Print Pascal's Triangle [duplicate]

Overview Pascal's triangle is the series of rows of numbers, starting with 1, where each cell is formed by summing the two above it. Here's an example. Challenge and Scoring The challenge is simple:...
5
votes
3answers
633 views

Wanna See a Card Trick? (Part I)

Amazingly, this is the easier of the three card tricks I know off the top of my head... The aim of this is to have your compiler perform a specific card trick. There's no slight of hand, and the ...
18
votes
23answers
1k views

Infer geometric sequences

Haskell has this neat(-looking) feature where you can give it three numbers and it can infer an arithmetic sequence from them. For example, [1, 3..27] is equivalent ...
0
votes
0answers
66 views

How many logs can you fit into a number? [duplicate]

Challenge Given a real number as input, calculate the number of times which the natural logarithm function ln can be applied to it before the resulting number ...
10
votes
5answers
399 views

Get Two from One

As we saw in this question complex logical statements can be expressed in terms of the simple connectives of generalized Minesweeper. However Generalized minesweeper still has redundancies. In order ...
21
votes
20answers
4k views

I want my book to be away from this table

Story So I have a book that I want to separate from my table with nothing but other books. I want to know how many books do I need to achieve this with \$n\$ book lengths. Here's a visualization ...
23
votes
27answers
2k views

Generalized matrix trace

Inspiration. Given (by any means): A two-argument (or single argument consisting of a two-element list) black box function, f: ℤ+ × ℤ+ → ℤ+ (input and output are ...
32
votes
50answers
4k 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 ...
26
votes
29answers
2k views

Rotation summation

Take a square matrix containing positive integers as input, and calculate the "rotated sum" of the matrix. Rotated sum: Take the sum of the original matrix and the same matrix rotated 90, 180 and ...
21
votes
22answers
2k views

Converting ISBN-13 to ISBN-10

Introduction In this challenge your task is to generate the ISBN-10 code for books given its ISBN-13 code, assuming that such a code exists. Such an ISBN-13 code consists of several parts separated ...
16
votes
5answers
852 views

Factoring factorials

Today in my statistics class, I found that some factorials can be simplified when multiplied together! For example: 5! * 3! = 5! *3*2 = 5! *6 = 6! Your job: Given ...
12
votes
4answers
229 views

Compute number of matrices with appropriate sums

When multiplying monomials in the Milnor basis for the Steenrod algebra, part of the algorithm involves enumerating certain "allowable matrices". Given two lists of nonnegative integers r1, ... ,rm ...
14
votes
16answers
869 views

Mod 2 Multinomial coefficients

quintopia has posted here a challenge to compute multinomial coefficients (some of the text here is copied from there). There is a fun algorithm to compute multinomial coefficients mod 2. Given a ...
8
votes
25answers
792 views

Are the numbers amicable?

Two numbers are considered amicable if the proper divisor sum of the first is the same as the second number, the second number's proper divisor sum is equal to the first number, and the first and ...
24
votes
62answers
3k views

The Non-Zero Digital Product Challenge

Originally the Multiplicative digital root Challenge Basically do what the title says Method Given a positive integer 1 <= N <= 100000000 through one of our standard input methods, multiply ...
24
votes
12answers
2k views

Write numbers as a difference of Nth powers

Challenge There are many numbers which can be expressed as the difference of two squares, or as the difference of two cubes, or maybe even higher powers. Talking about squares, there are various ways ...
10
votes
8answers
338 views

Collection from a sequence that constitute a perfect square

Given the sequence OEIS A033581, which is the infinite sequence, the n'th term (0-indexing) is given by the closed form formula 6 × n2 . Your task is to write code, which outputs all the subsets of ...
8
votes
20answers
1k views

Prime numbers between n and 2n [duplicate]

Bertrand's postulate states that there is always at least 1 prime number between n and 2n for all n greater than 1. Challenge Your task is to take a positive integer n greater than 1 and find all of ...
21
votes
16answers
2k views

Recursive Collatz Conjecture

The Collatz conjecture postulates that if you take any positive integer, then repeat the following algorithm enough times: ...
18
votes
37answers
2k views

Find the largest number of distinct integers that sum to n

The Task Given an input positive integer n (from 1 to your language's limit, inclusively), return or output the maximum number of distinct positive integers that ...
16
votes
1answer
513 views

Write it into number theory style

Write a mathematical statement, using the symbols: There exists at least one non-negative integer (written as E, existential ...
20
votes
16answers
2k views

Factor-poor numbers

If a positive integer \$N > 2\$ has (strictly) less prime factors (without counting multiplicities) than its successor and its predecessor, we will call it a factor-poor number. In other words, \$...
17
votes
1answer
286 views

Counting Moufang Loops

A loop is a pretty simple algebraic structure. It is a tuple (G,+) where G is a set and + is a binary operator G × G → G. That is + takes two elements from G and returns a new element. The operator ...
8
votes
2answers
251 views

Integer Division Loops

Challenge Given any positive integer supported by your language: Take the input and divide it into two halves. For all divisions in this program, if the input is odd, round one half up and one half ...
10
votes
2answers
486 views

Biggest square in a grid [closed]

Challenge Given a grid like this, ...
18
votes
13answers
2k views

Is it a Pascal Prime?

It is well known that odd primes will appear in Pascal's triangle exactly twice. However, not all numbers that appear exactly twice in Pascal's triangle are prime. We'll call these numbers Pascal ...
3
votes
1answer
281 views

Maximum Area of a Polygon with Vertices of a Polygon [closed]

Rules Given a list of integer coordinates, l, with a length of at least 4, and an integer n such that n is smaller than the length of l (but at least 3), return the largest area of an n-sided polygon ...
11
votes
6answers
315 views

Rhombus sequence

Imagine enumerating the elements of rhombi which grow [1],[1,3,1],[1,3,5,3,1],… (only odd numbers such that they align nicely). This would look like as follows, ...
17
votes
7answers
612 views

Approximate definite integrals using Riemann sums

Left and right Riemann sums are approximations to definite integrals. Of course, in mathematics we need to be very accurate, so we aim to calculate them with a number of subdivisions that approaches ...
16
votes
7answers
616 views

Queue Our Decomposition

In this challenge I will ask you to find a QR decomposition of a square matrix. The QR decomposition of matrix A is two Matrices Q and R such that A = QR. In particular we are looking for Q to be an ...
18
votes
7answers
2k views

Hilbert's binary Hotel

In this challenge you will be asked to implement any function (or full program) that fulfills two properties. Those properties are: Your function must be an injective (reversible) function from the ...
12
votes
3answers
248 views

Loan “generous” amounts of money

Introduction You have a friend that keeps asking you for loans and you are getting tired of it. Today, he came for a loan again. Instead of turning down his offer, you get a great idea: troll your ...
10
votes
3answers
233 views

Form a list using prime numbers

You have been given N piles of coins. You have decided to divide each of those B1, B2, ..., BN piles among separate groups of people. The amount of people receiving coins has to be a prime number and ...
16
votes
8answers
2k views

Be as evil as possible

Introduction This is a follow-up of this challenge where you're taking the role of that person's evil twin. Being evil you don't want to maximize your share, but rather be as unfair as possible and ...
22
votes
30answers
2k views

What is the missing number (divisibility by 9)

Challenge Given a whole number divisible by 9 and one missing digit, find the missing digit. The missing digit may be represented by any character other than the digits 0-9 as long as it is ...
62
votes
9answers
5k views

How lit is this mountain? 🔥

A mountain is defined to be a set of line segments whose first point has coordinates (0,a) where a > 0, and whose last point ...
16
votes
2answers
226 views

Program an Uncircularness Score

Your task is to program a mathematical function s, that takes a nonempty finite set A of points in the 2D plane, and outputs an ...
2
votes
6answers
211 views

52 Week Challenge [duplicate]

The 52 week challenge is a way to save money. For example, Week 1, you save $1.00. Week 2 you save $2.00, and it continues through the year, adding one more dollar to each week’s savings goal. By Week ...
3
votes
0answers
81 views

lexicographically sorted list of index [closed]

Given a drawing of the letter shoot system, where an existing piece of pipe is marked with a *, and an empty spot is marked with a ., your task is to compile a lexicographically sorted list of index ...
7
votes
2answers
262 views

Rational Polynomial Interpolation

Explanation In this task you'll be given a set of N points (x1,y1),…,(xN,yN) with distinct xi values and your task is to interpolate a polynomial through these points. If you know what Lagrange ...
14
votes
10answers
807 views

Decomposing into primes

Given an integer n, return the number of ways that n can be written as a list of prime numbers. For example, 2323 can be written ...
33
votes
33answers
5k views

Be as fair as possible

Introduction In this challenge you should split an integer into two pieces. Since nobody likes getting the smaller piece of cake, your goal is to be as fair as possible. For example if you wanted to ...
22
votes
26answers
4k views

Is it a pleasing number?

A pleasing number (according to this definition) is a number that can be passed through the following process (let's use 41802000 as an example): Separate the ...
7
votes
6answers
327 views

Count of relatively prime partitions

The partitions of an integer N are all the combinations of integers smaller than or equal to N and higher than 0 which sum up to N. A relatively prime partition is an integer partition, but whose ...
17
votes
6answers
713 views

Delete the first periodic digit

We all know that whenever a rational number is written in decimal, the result is either terminating or (eventually) periodic. For example, when 41/42 is written in decimal, the result is ...