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

learn more… | top users | synonyms

1
vote
5answers
193 views

Set Theory Operations Union Only [closed]

My obsession with set theory continues. I believe that most programming languages have neither sets as possible structures nor set theory operations such as Union and Intersection. If I am wrong then ...
13
votes
15answers
1k views

Length of String Using Set Theory

From Wikipedia Set-theoretic definition of natural numbers The set N of natural numbers is defined as the smallest set containing 0 and closed under the successor function S defined by S(n) = n ...
13
votes
27answers
1k views

Output the nth digits of an integer

Without using strings (except when necessary, such as with input or output) calculate the nth digit, from the left, of an integer (in base 10). Input will be given in this format: 726433 5 Output ...
13
votes
2answers
612 views

Lets take Beal's $1,000,000

Beal's Conjecture has a million dollar prize if you prove/disprove it. It states that if where A, B, C, x, y, and z are positive integers with x, y, z > 2, then A, B, and C have a common prime ...
30
votes
15answers
3k views

Solve the Global Debt, the Code Golf way

The leaders of the world have met and have finally admitted that the best (and only) way of resolving global economic woes is to take stock of how much they owe each other and just pay each other off ...
1
vote
7answers
321 views

Transpose a 3x3 matrix across the anti-diagonal

Write a program which takes a 3x3 matrix on stdin and prints its transpose along the anti-diagonal to stdout. You may assume that all elements of the matrix will be integers. Columns are ...
3
votes
13answers
695 views

Divide Two Numbers Using Long Division

Your challenge is to divide two numbers using long division. The method we used to use in old days of school to divide two numbers. Example here You should NOT use / or any other division operator ...
12
votes
6answers
1k views

My Robot Has Escaped the Lab!

My robot has short circuited somehow and randomly run off somewhere from my lab! Luckily, whenever he does this, his shut-down sequence initiates, giving him enough time to randomly turn and run in ...
50
votes
27answers
6k views

Mandelbrot image in every language

I always used a Mandelbrot image as the 'graphical' version of Hello World in any graphical application I got my hands on. Now it's your guys' turn. Language must be capable of graphical output or ...
19
votes
8answers
1k views

Calculate the inverse of factorial

Write the shortest code that will take any real number greater than 1 as input and will output its positive inverse factorial. In other words, it answers the question "what number factorial is equal ...
10
votes
45answers
4k views

Write a function that takes (x, y) and return x to the power of y WITHOUT Loops

This is a really neat short challenge. Write a function or a procedure that takes two parameters, x and y and returns the result of xy WITHOUT using loops, or built in power functions. The winner is ...
10
votes
5answers
312 views

Solve a System of Linear Equations

Write a program to solve a series of linear equations as short as possible. It must solve arbitrary number of equations problems. They can inputted however you like, coefficients of augmented matrix ...
2
votes
2answers
278 views

Get as close to pi as you can [closed]

Your job is to write a program to find the closest number to PI. Let me clarify. You will first choose a number type. Let us say you choose Integer (in an actual answer, you cannot). Your program ...
11
votes
23answers
907 views

Calculate all the squares up to x using only addition and subtraction

The goal is to calculate all the squares up to x with addition and subtraction. Rules: The code must be a function which takes the total number of squares to generate, and returns an array ...
8
votes
21answers
1k views

Calculate the cube root of a number

The goal of this code golf is to create a program or function that calculates and outputs the cube root of a number that's given as input. The rules: No external resources No use of built-in cube ...
5
votes
7answers
508 views

Shortest Program to Solve a Quartic Equation

Write the shortest program to solve a Quartic equation. A quartic equation is a polynomial equation of the form: ax⁴ +bx³+cx²+dx+e=0 A solution for x is a number such that the above evaluates to 0. ...
8
votes
10answers
876 views

3 and 5 Litre Jug Puzzle

You may have seen this one in Die Hard: With a Vengeance... This question is based on the famous 3 and 5 Litre Jug Puzzle, but with a slightly different slant. Golf up some code that when given an ...
1
vote
4answers
312 views

Theoretical algorithm to compute Graham's number

Graham's number G is defined in that way: 3^n = 3*..n times ...*3 3^^n = 3^(3^n) 3^^^n = 3^^(3^^n) 3^^^^n = 3^^^(3^^^n) g1 = 3^^^^3 g2 = 3^^...g1 times^^3 g3 = 3^^...g2 times^^3 ... G = 3^^...g63 ...
8
votes
5answers
376 views

Euler's Front 9

  Project Euler is another fun programming challenge site to compete (well, play) on. Early problems start off gently, but then explode in difficulty beyond the first hundred or so. The first ...
6
votes
8answers
492 views

Calculate the super root of a number

In mathematics, tetration is the next hyper operator after exponentiation, and is defined as iterated exponentiation. Addition (a succeeded n times) Multiplication (a added to itself, n times) ...
2
votes
1answer
106 views

Simplifying Radicals [duplicate]

Given integers a and b in the format a√b (a on the square root of b), make a program that will reduce b and increase a until the radical statement is fully simplified. Example input a = 1 b = 16 ...
24
votes
56answers
5k views

Count sum of all digits [Help to determine winner]

This challenge is to write a program or script which counts the sum of all digits within the integers from 1 up to and including a given number. Input, one positive integer. Output, the sum of digits ...
6
votes
5answers
192 views

Convert radicals to mixed & entire radicals and to real numbers

Challenge The goal of this challenge is to take a radical and convert it to a reduced and entire radical, and a real number. You do not have to convert it to all 3, however, you will get bonus points ...
6
votes
7answers
518 views

Minimum perimeter of an area

Just a simple code golf function for fun, intentionally left open with few rules to see what creativity comes up. Input: An integer representing the area of a rectangle. Output: Two integers ...
5
votes
13answers
437 views

Reciprocal Fibonacci constant

Seeing as there have been an awful lot of normal Fibonacci challenges, I decided that it might be interesting to calculate the Reciprocal Fibonacci constant - namely, the sum of the reciprocals of the ...
17
votes
8answers
656 views

Thinking outside the box

You are trying to fit a sphere into a 5-sided box, but sometimes it does not fit completely. Write a function to calculate how much of the sphere is outside (above the rim of) the box. There are 3 ...
2
votes
14answers
842 views

Write a mathematical function whose result is “hello world”

Write a mathematical function that results in an integer representation of "hello world" For example "hello world" in hex is 68656c6c6f20776f726c64 so the goal will be to write a mathematical ...
19
votes
5answers
545 views

Thar she blows!

Arrr... Ahoy there, me maties! Unfurl tha' mainsail! Full to starboard! Ah, feel th' wind in yer hair! Right, me hearties... I be needin' a bit of yer codin' skills! Me crew are a li'l more ...
11
votes
8answers
646 views

How long does it take to paint a stick?

(Based on this Math.SE problem, which also provides some graphics) I have a stick which looks kinda like this: I want it to look kinda like this: I'm not an expert painter, however, so before I ...
3
votes
3answers
331 views

Solve Any Motion Physics Problem (Equations Supplied)

Physics Challenge This program should be able to solve for ANY two of the following variables the user wants to solve. s (displacement) v (velocity) u (initial velocity) a (acceleration) t (time) ...
51
votes
14answers
11k views

9 Hole Challenge

The 9 Hole Challenge 9 code golfing challenges of varying difficulty. Penalties for using the same language more than once. The question will be updated with pars, hole champions and trophy ...
9
votes
1answer
318 views

Sunrise and sunset

I'm a bit of a romantic, I love taking my wife out to see the sunrises and sunsets in the place we are located. For the sake of this exercise let's say I don't have code that can tell me the time of ...
6
votes
7answers
263 views

Find a fraction's position in the Stern-Brocot tree

The Stern-Brocot tree is a binary tree of fractions where each fraction is acquired by adding the numerators and denominators of the two fractions neighbouring it in the levels above. It is generated ...
-2
votes
4answers
171 views

Write a function that results the sum of two integers using bitwise operations, w\o conditional operation [duplicate]

You cannot use if,while,for, ?:, ||, && etc., or recursion! Assume it is Int.32 Shortest answer wins
4
votes
3answers
382 views

Produce the most digits of an irrational number with only 64 KB of memory

Constraints: Calculate any notable irrational number such as pi, e, or sqrt(2) to as many decimal digits as possible. If using a number not mentioned in the list above, you must cite how and where ...
28
votes
29answers
3k views

Test a number for narcissism

A Narcissistic Number is a number which is the sum of its own digits, each raised to the power of the number of digits. For example, take 153 (3 digits): 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153 ...
11
votes
6answers
590 views

Convert 1 into any positive integer using only the operations *3 and /2

Any positive integer can be obtained by starting with 1 and applying a sequence of operations, each of which is either "multiply by 3" or "divide by 2, discarding any remainder". Examples (writing f ...
-8
votes
13answers
673 views

Calculate the factorial of a number without using recursion or loops

The goal of this code golf is to create a program that calculates the factorial of a positive number, without using recursion or loops. The rules: Your program should prompt for input. This input ...
6
votes
5answers
176 views

Golfing: How many unit-length squares in a list of 2d coordinates?

Given a list of 2d (x, y) coordinates, determine how many unit squares (edge length 1 unit) can be formed using the coordinates. Input will be an array of 0 or more pairs of coordinates: e.g. in ...
4
votes
7answers
331 views

Nth K-Ugly Number

Write the shortest code in any language of your choice to find the Nth K-ugly number. A K-ugly number is a number whose only prime factors are the prime numbers <= K. This K-ugly number is ...
9
votes
2answers
649 views

Implement superoptimizer for addition

The task is to write code that can find small logical formulae for sums of bits. The overall challenge is for your code to find the smallest possible propositional logical formula to check if the sum ...
3
votes
7answers
844 views

Generate an aperiodic integer sequence

Your task is to build a piece of code that generates an aperiodic sequence of integers, either by outputting one every time it iterates, or by taking an integer n and returning the nth number in that ...
20
votes
8answers
941 views

Too Fast, Too Fourier: FFT Code Golf

Implement the Fast Fourier Transform in the fewest possible characters. Rules: Shortest solution wins It can be assumed that the input is a 1D array whose length is a power of two. You may use the ...
6
votes
3answers
314 views

Simultaneous equations

With equations that have more than one unknown, simultaneous equations can be used in solving for them. This challenge will only deal with linear equations with two unknowns, to make things as ...
3
votes
2answers
191 views

Create sets with a Goldbach-like property

Goldbach's conjecture states that every even number > 4 is the sum of two prime numbers. Although this conjecture is not yet proven, similar results have been proven for other series of numbers. For ...
16
votes
29answers
2k views

Collatz Conjecture

This is the Collatz Conjecture: Start with an integer n > 1. Repeat the following steps: If n is even, divide it by 2. If n is odd, multiply it by 3 and add 1. It is proven that for all ...
15
votes
3answers
832 views

Four fours puzzle

The Four fours puzzle is a popular recreational mathematical puzzle that involves using exactly four 4s (and no other number) and a defined set of operations to reach every number from 0 to a given ...
7
votes
4answers
321 views

Fourth of July Edition: Print lines of a file containing multiples of a specific number

Create a program which takes one command-line argument, n, which will be an integer less than 2147483648 (2^31), and then reads a file input.txt and prints the lines of input.txt which contain any ...
18
votes
22answers
2k views

Define a function f such that f(f(n)) = -n for all non-zero integers n

This challenge was inspired by a programming blog I frequent. Please see the original post here: A Programming Puzzle Challenge Define a function f:Q->Q such that f(f(n)) = -n for all ...
7
votes
5answers
499 views

Generate Skolem sequences

Beat this I was hanging out with a friend in a pub around 11:00 last night. She told me that a Skolem sequence is a sequence of 2n numbers where every number between 1 and n is repeated twice, and ...