Menu

24 Solver

Enter four numbers and instantly find every 24 game solution — no guessing, no button clicks required.

Enter Four Numbers (1–13)

EditableComputed

Enter four integers (1–13), like playing cards. Results appear instantly.

Try:

Enter numbers above to see all solutions.

What Is a 24 Solver?

A 24 solver is a tool that takes four numbers and exhaustively finds every arithmetic expression — using addition, subtraction, multiplication, and division — whose value equals exactly 24. It automates what players do mentally during the classic card game invented by Robert Sun in 1988.

In the original game, each player draws four cards from a standard deck (Ace through King, valued 1–13) and races to announce an equation first. A solver removes the time pressure and reveals all valid equations, making it ideal for classroom practice, competition prep, or simply satisfying curiosity.

How to Solve for 24: 3 Worked Examples

The fastest mental strategy for finding a math 24 game solution is to anchor on factor pairs, then work backwards.

Case 1 — 5, 6, 7, 8

Step 1: Look for factor pair of 24 → 2 × 12
Step 2: Form 2 from two numbers → 8 − 6 = 2
Step 3: Form 12 from remaining → 5 + 7 = 12
✓ (8 − 6) × (5 + 7) = 2 × 12 = 24

Case 2 — 3, 7, 8, 9

Step 1: Look for factor pair of 24 → 3 × 8
Step 2: 3 is already in hand, 8 is already in hand
Step 3: Need 7 and 9 to cancel out → 7 + 9 − 8 = 8
✓ (7 + 9 − 8) × 3 = 8 × 3 = 24

Case 3 — 1, 5, 5, 5 (harder)

Step 1: Factor pairs don't use three 5s easily
Step 2: Try addition → 5 × 5 = 25, then 25 − 1 = 24
Step 3: But that only uses three numbers — need all four
Step 4: Rewrite → 5 × (5 − 1 / 5) = 5 × 4.8 = 24
✓ 5 × (5 − 1 / 5) = 5 × 24/5 = 24

24 Game Solver Formula & Algorithm

Every twenty four game solver runs the same exhaustive search under the hood. Given four numbers (a, b, c, d), the algorithm:

  1. Generates all 4! = 24 permutations of the four numbers.
  2. For each permutation, places three operators from [+, −, ×, ÷] in all 4³ = 64 combinations.
  3. Evaluates all 5 distinct parenthesisation shapes (binary expression trees with 4 leaves).
  4. Checks whether any result equals 24 within floating-point tolerance (<10⁻⁹).
Total expressions checked per input:
24 (perms) × 64 (ops) × 5 (trees) = 7,680
The 5 tree shapes correspond to:
((a ○ b) ○ c) ○ d
(a ○ (b ○ c)) ○ d
(a ○ b) ○ (c ○ d)
a ○ ((b ○ c) ○ d)
a ○ (b ○ (c ○ d))

Because division can produce rational numbers, intermediate values are tracked as exact fractions to avoid rounding errors — the same technique used in competitive programming judge systems.

Why Some Cards Can't Make 24 — Tricky Combinations

Not every hand is solvable. The solver confirms this by exhausting all 7,680 expressions and finding none equal 24. Understanding tricky 24 math answers (or the lack thereof) sharpens your mental arithmetic.

  • Impossible sets: roughly 1 in 14 four-card combinations has no solution (e.g., 1, 1, 1, 1 → max achievable is 4).
  • Fraction traps: 3, 3, 8, 8 requires 8 ÷ (3 − 8 ÷ 3) = 24 — impossible to spot without allowing intermediate fractions.
  • Negative intermediates: with 1, 5, 5, 5 the solution 5 × (5 − 1 / 5) = 24 passes through the fraction 1/5 as an intermediate step. The solver tests all branches including those with negative and fractional values.
  • Single-solution hands: some combinations like 1, 2, 3, 4 have dozens of solutions; others like 1, 6, 6, 8 have exactly one — enter them to see.

A useful heuristic for the challenge 24 solver variant: if you see a 1 in your hand, try multiplying it by 24 or using it to shift a product by 1. If you see two identical numbers, consider (a ÷ a) = 1 as a building block.

The Backtracking Algorithm Behind Every 24 Card Game Solver

The 24 card game solver is a textbook application of recursive backtracking — the same technique used in Sudoku solvers, N-Queens, and chess engines. This connection makes it a favourite interview problem at companies like Google and Meta.

Pseudocode (recursive approach)

function solve(numbers):
if len(numbers) == 1:
return abs(numbers[0] - 24) < 1e-9
for each pair (i, j) in numbers:
for each operator op in [+, -, *, /]:
result = apply(numbers[i], numbers[j], op)
if result is not None: # skip division by zero
remaining = numbers without i and j
if solve(remaining + [result]):
return True
return False

In engineering contexts, the same pattern appears in expression evaluators, compiler AST builders, and symbolic math systems. The key insight — reduce two operands to one result, then recurse — is a reusable primitive for any "combine items with operators" problem.

Unlike brute-force enumeration, the recursive approach prunes impossible branches early (e.g., division by zero) and naturally handles all tree structures without explicitly enumerating them as a separate step.

Frequently Asked Questions

How do I use this 24 game solver?
Enter four integers between 1 and 13 in the input fields. The solver instantly displays every arithmetic expression that combines those numbers to equal 24 using +, −, ×, and ÷.
What equals 24 using four numbers?
Many combinations work. For example, with 5, 6, 7, 8 one valid expression is (8 − 6) × (5 + 7) = 2 × 12 = 24. The solver finds every solution for any four numbers you enter.
How to get 24 from four cards?
Enter the face values (Ace=1, Jack=11, Queen=12, King=13). The solver checks all 7,680 expression trees and lists every equation that reaches exactly 24.
How to play the 24 game?
Draw four cards from a standard deck. Each player races to form an arithmetic expression equal to 24 using all four face values exactly once. First correct answer wins the round.
Can you make 24 from 3, 3, 8, 8?
Yes: 8 ÷ (3 − 8 ÷ 3) = 24. It requires nested fractions, making it one of the most famous tricky combinations in the game.
Why can't some four-number sets make 24?
About 1 in 14 card combinations is provably impossible. The exhaustive search checks all permutations and operator trees; if none yields 24, no solution exists.
How to solve 24 game fast in your head?
Start with factor pairs of 24 (1×24, 2×12, 3×8, 4×6). Check whether remaining numbers can produce one factor through addition or subtraction from the other numbers.
Does the 24 solver handle fractions and negative numbers?
Yes. Intermediate results can be fractions or negative numbers as long as the final value is exactly 24. Division by zero is automatically excluded.

Related Calculators