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

learn more… | top users | synonyms

0
votes
2answers
190 views

Solving Systems of Equations using Cramer's Rule

Create an algorithm that uses Cramer's Rule (with determinants of matrices) to solve for the solutions of a system of linear equations. The code should work for an "n" number of variables. You may ...
2
votes
0answers
92 views

Write program which finds shortest expression for number [duplicate]

Write program which finds shortest expression for big integer. Expression may consist of + - * / ^ ! ( ) operations. ! stands for factorial, ^ - exponentiation, / - rational division. Number itself ...
3
votes
0answers
193 views

Write a FAST word equation solver [duplicate]

This question is similar to Write a word equation solver by David Frank but different in three important ways: (1) David asked for just the first solution found, and I am asking for all the solutions. ...
8
votes
3answers
386 views

Calculate to how many cubes one cube can be cut

Imagine some cube which we can cut into smaller cubes without remaining pieces. Find to how many cubes a cube can be cut. For example, a cube can be cut into 8, 27 (obviously 3rd powers of integers) ...
11
votes
8answers
2k views

Write program which verifies Erdős–Straus conjecture

Write program, which verifies Erdős–Straus conjecture. Program should take as input one integern (3 <= n <= 1 000 000) and print triple of integers satisfying identity 4/n = 1/x + 1/y + 1/z, 0 ...
-1
votes
0answers
87 views

Traverse resultant 2d array after integer partition [on hold]

I have used the solution of integer partitioning using dynamic programming explained in this post and in this article. Following is the resultant matrix when N is equal to 6: 1 1 1 1 1 1 1 0 1 1 1 ...
5
votes
5answers
311 views

Permutation Numbering

The Challenge For a given set of n integers, write a program which will output its lexicographic index. The Rules The input must only be a set of unique non-negative integers separated by spaces. ...
-2
votes
0answers
69 views

Preliminary Assignment [on hold]

A. Make a program that would count number divisible by specified divisor. It would also count a set of numbers where a number(s) with that set is divisible by specified divisor. Sample output ...
18
votes
13answers
1k views

Khinchin's constant to as many decimal places as possible in 64 bytes or less

Khinchin's constant is a curious mathematical constant that, according to Wolfram MathWold, is "notoriously difficult to calculate to high precision". Here it is to 100 digits: ...
6
votes
5answers
446 views

Output nth term in Catalan type sequence

Given a number, starting with 1, create new numbers (children) by taking the last digit, n, and concatenating 1 through n+1. This seems to be a much better explanation of the sequence A071159. ...
3
votes
4answers
387 views

Difference of expressions when evaluated in different orders

We all know the standard order of operations for math functions (PEMDAS), but what if we instead evaluated expressions left-to-right? The Challenge Given a string through standard input or through ...
0
votes
2answers
259 views

Solve this math problem in smallest amount of code [closed]

Here I found a cool math problem. I thought you could write some golfed code to compute all answers between x and x.(there is an infinite amount). Problem: Once upon a time, and old lady went to sell ...
5
votes
5answers
429 views

Operations on Sets

Note: I have accepted an answer, but I'm willing to accept a better answer if it comes. Write a program that computes operations on sets. You may take input either from standard input or from command ...
47
votes
14answers
7k views

“Disprove” Fermat's Last Theorem

Write a program, in the language of your choice, that appears to successfully find a counterexample to Fermat's Last Theorem. That is, find integers a, b, c > 0 and n > 2 such that an + bn = cn. Of ...
3
votes
1answer
207 views

Finding internal rate of return (IRR)

In investing, internal rate of return (IRR), the continuously compounded rate of return economically equivalent to a specified series of cashflows, is often a valuable concept. Your challenge is to ...
4
votes
2answers
604 views

Longest mathematical expression in a grid

Given a grid which contains these signs: 0..9, x, =, write the fastest code that outputs the longest string of connected (horizontally, vertically, and diagonally adjacent), distinct cells which is a ...
15
votes
7answers
1k views

Write a word equation solver

Introduction Consider the following example: CODE + GOLF —————— GREAT This is an equation where each letter represents a decimal digit and the words represent natural numbers (similar letters ...
21
votes
13answers
3k views

Calculate `n % 12`

Calculate n modulo 12 for an unsigned 32 bit integer. The Rules: Must work for all n between 0 and 23. Other numbers optional. Must only use any of the operators +-*, ~&^| or <<, ...
27
votes
7answers
2k views

Newtons Method by Recursive Quines

Newtons Method by Recursively Generating Code Your task is to calculate the square root of 2 using Newton's Method - with a slight twist. Your program is to calculate an iteration using Newton's ...
46
votes
9answers
3k views

Help me with differential calculus!

I love programming and know every language, but I suck at math. Unfortunately, my school requires that computers students must take a year of calculus. There's a test next week, and I don't know any ...
4
votes
0answers
184 views

Approximate square root from algorithm time complexity

There have been a few square root challenges lately, but I think this one is different. Challenge Find an algorithm such that the worst case time complexity is proportional to n^2 and the best case ...
51
votes
2answers
1k views

“KNOT” or “NOT”?

Write a program that processes an ASCII art representation of a tangled string and decides whether or not it can be untangled into a simple loop. The tangle is represented using the characters - and | ...
11
votes
6answers
1k views

Fast Trig Calculation

Fast Trigonometry Calculations Your task is to create a program which can calculate the sine, cosine and tangent of an angle in degrees. Rules No built-in trigonometry functions (not even secant, ...
4
votes
16answers
830 views

Find all numbers between 2 and 100 co-prime to a given number

Your program will be given a number as input. Your challenge is to output all the numbers between 2 and 100 inclusive that are co-prime to the given number. (Two numbers are co-prime if their GCD is ...
3
votes
2answers
376 views

Find number of polynomials with a root which is a root of unity

Write a program which takes an integer argument and outputs the number of degree n monic polynomials with coefficients that are -1,1 or 0 which have a root which is a root of unity. To make it a ...
253
votes
95answers
137k views

Write a program that makes 2 + 2 = 5

Write a program that seemingly adds the numbers 2 and 2 and outputs 5. This is an underhanded contest. Your program cannot output any errors. Watch out for memory holes! Input is optional. ...
48
votes
18answers
6k views

Program that adds all natural numbers and yields -1/12

As you might know there is a mathematical fun-fact that if you add all natural numbers you end up with... -1/12 (see Wikipedia here). Of course this is very strange result and can not be obtained by ...
-1
votes
3answers
141 views

Puzzle : Find minimum resource allocation on multiple of 10 or 12 only [closed]

I have two types of notebook . 10 problems could be solved in one page, in the first notebook. 12 problems could be solved in one page, in the second notebook. For given n problems I have to use ...
20
votes
16answers
3k views

Let the trigonometry begin!

Introduction: The sine of x is given by the formula: sin(x) = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! - x^11/11! // and more follows... The cosine of x is given by the formula: cos(x) = 1 - x^2/2! ...
13
votes
19answers
1k views

Print the prime factorization of the greatest common divisor of two numbers

Title says it all. Two input 32-bit positive integers m, n >= 2, output gcd(m,n) in prime factorization form. Input Command line args or 1 line of stdin okay, whatever's better for golf. Output ...
3
votes
0answers
407 views

Collatz Attack!

This challenge is based on some new findings related to the Collatz conjecture and designed somewhat in the spirit of a collaborative polymath project. Solving the full conjecture is regarded as ...
11
votes
5answers
564 views

Animate a Rotating Lissajous Figure

Entries for this challenge will display an animated rotating Lissajous figure. The appearance of 3d rotation occurs as the x parameter is successively phase-shifted in each frame. Input: The a and ...
14
votes
5answers
1k views

Closest fraction

Task: Your program is given a proper, positive simple fraction in the format <numerator>/<denominator>. For this input, it must find two fractions. A fraction that is less than the ...
1
vote
1answer
97 views

Convert image pixels to quadruples [closed]

Example given an image which width and height is a power of two . First step : Divide each image into Cartesian coordinate quadrants _____ _____ | | | | 2 | 1 | |_____|_____| | | ...
1
vote
5answers
214 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 ...
14
votes
16answers
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
28answers
2k 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 ...
14
votes
2answers
704 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 ...
31
votes
15answers
4k 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
479 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 ...
4
votes
13answers
901 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
7k 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 ...
21
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 ...
11
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
377 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
348 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
937 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 ...
9
votes
20answers
2k 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
574 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. ...