How to use the 24 game solver
- Enter your four numbers in the input fields above.
- The solver instantly searches all permutations of numbers, operators and parentheses.
- Review the list of unique expressions that evaluate to exactly 24.
- If no solutions appear, the number combination cannot produce 24 under standard rules.
How the solver works
The 24 game asks you to combine four numbers using only +, -, * and / to reach exactly 24. A brute-force search evaluates every possibility. There are 4! = 24 ways to order the numbers, 43 = 64 ways to pick three operators and 5 distinct binary tree shapes for placing parentheses. That gives 24 x 64 x 5 = 7,680 candidate expressions.
For each expression the solver computes the result using exact rational arithmetic (tracking numerators and denominators as integers) to avoid floating-point rounding errors. If the final fraction equals 24/1, the expression is kept. Duplicate strings are filtered out before display.
Common solvable sets
Many popular 24 game cards have multiple solutions. Here are a few well-known sets and one valid expression for each:
| Numbers | Solution |
|---|---|
| 1, 2, 3, 4 | ((1 * 2) * 3) * 4 |
| 1, 5, 5, 5 | (5 - (1 / 5)) * 5 |
| 3, 3, 8, 8 | 8 / (3 - (8 / 3)) |
| 6, 6, 6, 6 | ((6 + 6) + 6) + 6 |
| 1, 4, 5, 6 | 4 / (1 - (5 / 6)) |
| 2, 7, 8, 9 | ((7 + 9) * 2) - 8 |
The set 1, 5, 5, 5 is famous because it requires a fraction during intermediate steps. You must compute 1 / 5 first, subtract it from 5 to get 24/5, then multiply by 5.
Impossible combinations
Not every group of four numbers can make 24. For example, 1, 1, 1, 1 has a maximum reachable value of 4 (using ((1 + 1) + 1) + 1), so 24 is impossible. Other unsolvable sets include 1, 1, 1, 2 and 8, 8, 8, 8. When playing with a standard deck, roughly 80 percent of random four-card draws have at least one solution, depending on whether face cards count as 10 or their printed values.
If this 24 math game solver returns no results, the combination genuinely has no solution under standard rules. Some house rules allow concatenation (treating 1 and 2 as 12) or exponentiation, but those variants are not supported here.
Rational arithmetic vs floating point
A naive approach might use JavaScript's native Number type and check if the result is close to 24. This fails for tricky cases like 3, 3, 8, 8. The expression 8 / (3 - (8 / 3)) involves dividing 8 by one-third, which should yield exactly 24. However, floating-point representation of 8 / 3 introduces tiny rounding errors that compound through subsequent operations.
To guarantee accuracy, this solver tracks every intermediate value as a fraction p/q where both parts are integers. Addition, subtraction, multiplication and division of fractions follow exact algebraic rules. Only at the end does it check whether p === 24 * q. This ensures no valid solution is missed and no false positive is shown.
Tips for solving manually
When you want to practice without a tool, look for factor pairs of 24 first: 6 x 4, 8 x 3, 12 x 2 and 24 x 1. Try to split your four numbers into two groups that produce each factor. For instance, given 2, 3, 4, 6, notice that 6 * 4 = 24 and 3 - 2 = 1, so (6 * 4) * (3 - 2) works.
Another strategy is aiming for a nearby round number and adjusting. If three of your numbers easily make 25 or 23, see if the fourth can bridge the gap. Division-heavy puzzles like 1, 5, 5, 5 require thinking in fractions rather than whole numbers, which is why a 24 math game solver is handy for verifying unusual approaches.
Worked examples
Each result below was produced by the same code the tool runs, so you can check your own numbers against them.
| Example | Input | Result |
|---|---|---|
| Classic hard set (1, 5, 5, 5) | Number 1: 1; Number 2: 5; Number 3: 5; Number 4: 5 | (5 - (1 / 5)) * 5, 5 * (5 - (1 / 5)) |
| Consecutive (1, 2, 3, 4) | Number 1: 1; Number 2: 2; Number 3: 3; Number 4: 4 | ((1 + 2) + 3) * 4, (1 + (2 + 3)) * 4, ((1 * 2) * 3) * 4, (1 * (2 * 3)) * 4, (1 * 2) * (3 * 4), 1 * ((2 * 3) * 4), 1 * (2 * (3 * 4)), ((1 * 2) * 4) * 3, (1 * (2 * 4)) * 3, (1 * 2) * (4 * 3), 1 * ((2 * 4) * 3), 1 * (2 * (4 * 3)), (1 + 3) * (2 + 4), ((1 + 3) + 2) * 4, (1 + (3 + 2)) * 4, ((1 * 3) * 2) * 4, (1 * (3 * 2)) * 4, (1 * 3) * (2 * 4), 1 * ((3 * 2) * 4), 1 * (3 * (2 * 4)), (1 + 3) * (4 + 2), ((1 * 3) * 4) * 2, (1 * (3 * 4)) * 2, (1 * 3) * (4 * 2), 1 * ((3 * 4) * 2), 1 * (3 * (4 * 2)), ((1 * 4) * 2) * 3, (1 * (4 * 2)) * 3, (1 * 4) * (2 * 3), 1 * ((4 * 2) * 3), 1 * (4 * (2 * 3)), ((1 * 4) * 3) * 2, (1 * (4 * 3)) * 2, (1 * 4) * (3 * 2), 1 * ((4 * 3) * 2), 1 * (4 * (3 * 2)), ((2 + 1) + 3) * 4, (2 + (1 + 3)) * 4, ((2 * 1) * 3) * 4, (2 * (1 * 3)) * 4, (2 * 1) * (3 * 4), 2 * ((1 * 3) * 4), 2 * (1 * (3 * 4)), ((2 / 1) * 3) * 4, (2 / 1) * (3 * 4), (2 / (1 / 3)) * 4, 2 / (1 / (3 * 4)), 2 / ((1 / 3) / 4), ((2 * 1) * 4) * 3, (2 * (1 * 4)) * 3, (2 * 1) * (4 * 3), 2 * ((1 * 4) * 3), 2 * (1 * (4 * 3)), ((2 / 1) * 4) * 3, (2 / 1) * (4 * 3), (2 / (1 / 4)) * 3, 2 / (1 / (4 * 3)), 2 / ((1 / 4) / 3), ((2 + 3) + 1) * 4, (2 + (3 + 1)) * 4, ((2 * 3) * 1) * 4, (2 * (3 * 1)) * 4, (2 * 3) * (1 * 4), 2 * ((3 * 1) * 4), 2 * (3 * (1 * 4)), ((2 * 3) / 1) * 4, (2 * (3 / 1)) * 4, 2 * ((3 / 1) * 4), (2 * 3) / (1 / 4), 2 * (3 / (1 / 4)), ((2 * 3) * 4) * 1, (2 * (3 * 4)) * 1, (2 * 3) * (4 * 1), 2 * ((3 * 4) * 1), 2 * (3 * (4 * 1)), ((2 * 3) * 4) / 1, (2 * (3 * 4)) / 1, (2 * 3) * (4 / 1), 2 * ((3 * 4) / 1), 2 * (3 * (4 / 1)), (2 + 4) * (1 + 3), ((2 * 4) * 1) * 3, (2 * (4 * 1)) * 3, (2 * 4) * (1 * 3), 2 * ((4 * 1) * 3), 2 * (4 * (1 * 3)), ((2 * 4) / 1) * 3, (2 * (4 / 1)) * 3, 2 * ((4 / 1) * 3), (2 * 4) / (1 / 3), 2 * (4 / (1 / 3)), (2 + 4) * (3 + 1), ((2 * 4) * 3) * 1, (2 * (4 * 3)) * 1, (2 * 4) * (3 * 1), 2 * ((4 * 3) * 1), 2 * (4 * (3 * 1)), ((2 * 4) * 3) / 1, (2 * (4 * 3)) / 1, (2 * 4) * (3 / 1), 2 * ((4 * 3) / 1), 2 * (4 * (3 / 1)), (3 + 1) * (2 + 4), ((3 + 1) + 2) * 4, (3 + (1 + 2)) * 4, ((3 * 1) * 2) * 4, (3 * (1 * 2)) * 4, (3 * 1) * (2 * 4), 3 * ((1 * 2) * 4), 3 * (1 * (2 * 4)), ((3 / 1) * 2) * 4, (3 / 1) * (2 * 4), (3 / (1 / 2)) * 4, 3 / (1 / (2 * 4)), 3 / ((1 / 2) / 4), (3 + 1) * (4 + 2), ((3 * 1) * 4) * 2, (3 * (1 * 4)) * 2, (3 * 1) * (4 * 2), 3 * ((1 * 4) * 2), 3 * (1 * (4 * 2)), ((3 / 1) * 4) * 2, (3 / 1) * (4 * 2), (3 / (1 / 4)) * 2, 3 / (1 / (4 * 2)), 3 / ((1 / 4) / 2), ((3 + 2) + 1) * 4, (3 + (2 + 1)) * 4, ((3 * 2) * 1) * 4, (3 * (2 * 1)) * 4, (3 * 2) * (1 * 4), 3 * ((2 * 1) * 4), 3 * (2 * (1 * 4)), ((3 * 2) / 1) * 4, (3 * (2 / 1)) * 4, 3 * ((2 / 1) * 4), (3 * 2) / (1 / 4), 3 * (2 / (1 / 4)), ((3 * 2) * 4) * 1, (3 * (2 * 4)) * 1, (3 * 2) * (4 * 1), 3 * ((2 * 4) * 1), 3 * (2 * (4 * 1)), ((3 * 2) * 4) / 1, (3 * (2 * 4)) / 1, (3 * 2) * (4 / 1), 3 * ((2 * 4) / 1), 3 * (2 * (4 / 1)), ((3 * 4) * 1) * 2, (3 * (4 * 1)) * 2, (3 * 4) * (1 * 2), 3 * ((4 * 1) * 2), 3 * (4 * (1 * 2)), ((3 * 4) / 1) * 2, (3 * (4 / 1)) * 2, 3 * ((4 / 1) * 2), (3 * 4) / (1 / 2), 3 * (4 / (1 / 2)), ((3 * 4) * 2) * 1, (3 * (4 * 2)) * 1, (3 * 4) * (2 * 1), 3 * ((4 * 2) * 1), 3 * (4 * (2 * 1)), ((3 * 4) * 2) / 1, (3 * (4 * 2)) / 1, (3 * 4) * (2 / 1), 3 * ((4 * 2) / 1), 3 * (4 * (2 / 1)), 4 * ((1 + 2) + 3), 4 * (1 + (2 + 3)), ((4 * 1) * 2) * 3, (4 * (1 * 2)) * 3, (4 * 1) * (2 * 3), 4 * ((1 * 2) * 3), 4 * (1 * (2 * 3)), ((4 / 1) * 2) * 3, (4 / 1) * (2 * 3), (4 / (1 / 2)) * 3, 4 / (1 / (2 * 3)), 4 / ((1 / 2) / 3), 4 * ((1 + 3) + 2), 4 * (1 + (3 + 2)), ((4 * 1) * 3) * 2, (4 * (1 * 3)) * 2, (4 * 1) * (3 * 2), 4 * ((1 * 3) * 2), 4 * (1 * (3 * 2)), ((4 / 1) * 3) * 2, (4 / 1) * (3 * 2), (4 / (1 / 3)) * 2, 4 / (1 / (3 * 2)), 4 / ((1 / 3) / 2), 4 * ((2 + 1) + 3), 4 * (2 + (1 + 3)), (4 + 2) * (1 + 3), ((4 * 2) * 1) * 3, (4 * (2 * 1)) * 3, (4 * 2) * (1 * 3), 4 * ((2 * 1) * 3), 4 * (2 * (1 * 3)), ((4 * 2) / 1) * 3, (4 * (2 / 1)) * 3, 4 * ((2 / 1) * 3), (4 * 2) / (1 / 3), 4 * (2 / (1 / 3)), 4 * ((2 + 3) + 1), 4 * (2 + (3 + 1)), (4 + 2) * (3 + 1), ((4 * 2) * 3) * 1, (4 * (2 * 3)) * 1, (4 * 2) * (3 * 1), 4 * ((2 * 3) * 1), 4 * (2 * (3 * 1)), ((4 * 2) * 3) / 1, (4 * (2 * 3)) / 1, (4 * 2) * (3 / 1), 4 * ((2 * 3) / 1), 4 * (2 * (3 / 1)), 4 * ((3 + 1) + 2), 4 * (3 + (1 + 2)), ((4 * 3) * 1) * 2, (4 * (3 * 1)) * 2, (4 * 3) * (1 * 2), 4 * ((3 * 1) * 2), 4 * (3 * (1 * 2)), ((4 * 3) / 1) * 2, (4 * (3 / 1)) * 2, 4 * ((3 / 1) * 2), (4 * 3) / (1 / 2), 4 * (3 / (1 / 2)), 4 * ((3 + 2) + 1), 4 * (3 + (2 + 1)), ((4 * 3) * 2) * 1, (4 * (3 * 2)) * 1, (4 * 3) * (2 * 1), 4 * ((3 * 2) * 1), 4 * (3 * (2 * 1)), ((4 * 3) * 2) / 1, (4 * (3 * 2)) / 1, (4 * 3) * (2 / 1), 4 * ((3 * 2) / 1), 4 * (3 * (2 / 1)) |
| All sixes (6, 6, 6, 6) | Number 1: 6; Number 2: 6; Number 3: 6; Number 4: 6 | ((6 + 6) + 6) + 6, (6 + (6 + 6)) + 6, (6 + 6) + (6 + 6), 6 + ((6 + 6) + 6), 6 + (6 + (6 + 6)), (6 * 6) - (6 + 6), ((6 * 6) - 6) - 6 |
| Impossible set (1, 1, 1, 1) | Number 1: 1; Number 2: 1; Number 3: 1; Number 4: 1 | No solution found. |
FAQ
What are the rules of the 24 game?
You must use four given numbers exactly once each, combined with addition, subtraction, multiplication and division plus any arrangement of parentheses, to produce exactly 24.
Can every set of four numbers make 24?
No. Sets like 1, 1, 1, 1 and 8, 8, 8, 8 cannot reach 24. About 80 percent of draws from a standard deck are solvable under common rule variations.
Does the order of numbers matter?
The solver tests all 24 permutations automatically, so you can enter the four numbers in any order.
Are negative numbers allowed?
Yes. You can enter negative integers and the solver will consider them. Standard card-based play uses only positive values, but the math supports negatives.
Why does 1, 5, 5, 5 work?
The expression (5 - (1 / 5)) * 5 evaluates to (24 / 5) * 5 which equals 24. It requires an intermediate fraction, making it one of the hardest classic puzzles.
Is my data sent anywhere?
No. All computation happens locally in your browser. Nothing is uploaded to any server.