# Questions tagged [math]

The challenge involves mathematics in some central way. Also consider using more specific tags, listed in the tag wiki info.

606 questions
Filter by
Sorted by
Tagged with
4k views

### Fibonacci-orial

Definition Fibonacci sequence F(n), on the positive integers, are defined as such: ...
• 49.6k
6k views

### Divisibility test

Task Given two strictly positive integers n and d as input, determine whether n is evenly divisible by d, i.e., if there exists an integer q such that n = qd. You ...
• 49.6k
13k views

### The rice and chess problem

An Indian legend tells the story of the alleged inventor of the chess game, who impressed the emperor of India with his game so much that he would get rewarded with anything asked. The man said he ...
• 775
2k views

### World Big Dosa​

You are a talented young chef who has just been offered the position of sous chef at the world's most prestigious Indian restaurant. You have little experience with preparing Indian cuisine, but you'...
• 24.6k
5k views

### Is it a Proth number?

A Proth number, named after François Proth, is a number that can be expressed as $$N = k \times 2^n + 1$$ Where $k$ is an odd positive integer and $n$ is a positive integer such that $2^n > k$...
• 58.9k
4k views

### Natural Pi #0 - Rock

Goal Create a program/function that takes an input N, check if N random pairs of integers are relatively prime, and returns <...
• 5,716
7k views

Background Adler-32 is a 32-bit checksum invented by Mark Adler in 1995 which is part of the widely used zlib library (also developed by Adler). Adler-32 is not as reliable as a 32-bit cyclic ...
• 210k
3k views

### Help me carry my shopping bags

It was a warm summer evening... when my stupid car decided to break down in the middle of the road on my way back from the supermarket. I pushed it to the sideline and decided to walk home. I opened ...
• 1,504
6k views

### The Bowlers-Golfers Fraction War

Introduction Let's start by arranging all fractions from 0 to 1 in order of lowest denominator, then lowest numerator: 1/2, 1/3, 2/3, 1/4, 3/4, 1/5, 2/5, 3/5, 4/5, 1/6, 5/6, 1/7... Note that ...
• 10.8k
2k views

### Co-primality and the number pi

Introduction Number theory is full of wonders, in the form of unexpected connections. Here's one of them. Two integers are co-prime if they have no factors in common other than 1. Given a number $N$,...
• 104k
4k views

### My Word can beat up your Word

PROBLEM Given two words, find the winner in a digital root battle. Define the digital root of a word this way: Each letter of the alphabet is assigned a number: A = 1, B = 2, C = 3, ..., Z = 26 ...
• 675
3k views

### Bijective function ℤ → ℤⁿ

It is trivially possible to create a bijective function from $\mathbb{Z}$ (the set of all integers) to $\mathbb{Z}$ (e.g. the identity function). It is also possible to create a bijective ...
• 15.4k
1k views

### Every Possible Cycle Length

A function (or program) which takes inputs and provides outputs can be said to have a cycle if calling the function on its own output repeatedly eventually reaches the original number. For instance, ...
• 42k
4k views

### Reimplementing square root [duplicate]

Define a function, s, which takes a number and returns the square root. No use of library functions, such as Java's Math.sqrt() or PHP's built in sqrt(), allowed.
• 1,145
5k views

### The Möbius Function

The Möbius function is an important number theoretic function. Your submission should accept a positive integer $n$ and return the value of the Möbius function evaluated at $n$. Definition The ...
• 43.7k
5k views

### Chinese Remainder Theorem

The Chinese Remainder Theorem tells us that we can always find a number that produces any required remainders under different prime moduli. Your goal is to write code to output such a number in ...
• 144k
2k views

### Polynomialception

Given two polynomials f,g of arbitrary degree over the integers, your program/function should evaluate the first polynomial in the second polynomial. ...
• 43.7k
6k views

### A penny saved is a penny

...counted! You will pass your program a variable which represents a quantity of money in dollars and/or cents and an array of coin values. Your challenge is to output the number of possible ...
• 411
3k views

• 4,302
1k views

### Find the repetend of the decimal representation!

In this challenge 2 years ago, we found the period of a unit fraction (1/n where n is a natural number). Now, your task is to write a program/function to find the ...
• 49.6k
1k views

### Calculate the vector component

Challenge Assume two vectors $\mathbf{a} = (a_1,a_2,\cdots,a_n)$ and $\mathbf{b} = (b_1,b_2,\cdots,b_n)$ are given in an $n$-dimensional space, where at least one of $b_1,\cdots,b_n$ is ...
• 73.8k
2k views

### Verify Magic Square

A magic square is a square array of numbers with side n consisting of the distinct positive integers 1, 2, ..., n² arranged such that the sum of the n numbers in any horizontal, vertical, or main ...
888 views

### Bijection between binary strings and pairs thereof

Input: Either one or two strings consisting of '0's and '1's. If there are 2, they are separated by a space. All strings are of ...
• 6,198
1k views

### Transmit Pi... precisely

Following on from Monte Carlo estimator of Pi this challenge is to produce the shortest code for the constant Pi. Except here your code must output consecutive digits of pi forever. This is code ...
955 views

### Raise to the Power

Challenge Challenge is writing a program that takes a positive numbers a and a nonzero number b and outputs ...
• 43.7k
1k views

### Math in manhattan

I define the following operators: Manhattan Addition a +M b, for single-digit numbers, is the result of concatenating b onto a. So, a +M b = 10a + b. Therefore, the general operator +M is defined as ...
• 39.9k
2k views

### Fibonacci domino tiling

There's classic combinatorial result that the number of ways to tile a 2*n strip by 1*2 dominoes is the nth Fibonacci number. ...
• 144k
973 views

### Calculate probability of getting half as many heads as coin tosses.

Write a program that, given a small positive even integer from standard input, calculates the probability that flipping that many coins will result in half as many heads. For example, given 2 coins ...
• 693
4k views

### Write a mathematical function whose result is "hello world" [closed]

Write a mathematical function that results in an integer representation of "hello world" For example "hello world" in hex is 68656c6c6f20776f726c64 so the goal ...
• 409
389 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 ...
• 16.7k
882 views

### Code Golf: Number of paths!

Challenge Consider a square matrix of order N(N rows and N columns). At each step you can move one step to the right or one step to the top. How many possibilities are to reach (N,N) from ...
• 2,359
2k views

### Amicable number calculator [closed]

Write a program that calculates amicable numbers, starting from [0,0], intil the maximum value for an integer is reached in the language you chose to write it in. Amicable numbers are two different ...
861 views

Challenge: Write the smallest program (in characters) that resolves quadratic equations i.e. ax² + bx + c = 0 Rules: Given 3 numbers in R comma-delimited on ...
• 967
1k 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) ...
• 1,391
30k views

### Mathematics is fact. Programming is not

In mathematics an exclamation mark ! often means factorial and it comes after the argument. In programming an exclamation mark ! ...
• 89.3k
7k views

### Does the code terminate?

This is a code golf challenge I thought of with a mathematical bent. The challenge is to write the shortest code possible such that it is an open question whether or not the code terminates. An ...
• 1,037