24 Game Solver

Enter four numbers (typically 1–13) or click Random to generate them. Find every way to make 24 using addition, subtraction, multiplication, division, and parentheses. Multiple solutions are displayed instantly.

Enter integers from 1 to 13 (classic 24 game range). Default: 3,3,8,8 (8/(3–8/3)=24).
? 3,3,8,8
? 1,4,5,6
? 1,3,4,6
⚡ 2,2,2,2
? 4,4,4,4
❓ 1,1,1,1
Privacy first: All solving is done locally – no data leaves your device.

What is the 24 Game?

The 24 Game is an arithmetical puzzle where the goal is to combine four integers (usually from 1 to 13) using the basic operations (+, –, ×, ÷) to obtain 24. Parentheses can be used to change the order of operations. For example, with 3, 3, 8, 8, a classic solution is 8 ÷ (3 – 8 ÷ 3) = 24. The game sharpens mental arithmetic and strategic thinking.

Given four numbers a, b, c, d, find an expression E(a,b,c,d) = 24 using +, –, ×, ÷ and parentheses.

Origins & Cultural Impact

The 24 Game was invented by Robert Sun in 1988 and first published by Suntex International. It quickly became a classroom favorite for building mental math skills. Today it is played worldwide, with tournaments and online versions. The game’s depth lies in its simplicity: some sets have no solution (e.g., 1,1,1,1), while others have dozens. It naturally introduces fractions, factoring, and order of operations.

Why Use an Interactive Solver?

  • Learning Aid: See step‑by‑step solutions to understand different strategies (making 8×3, 12+12, fraction complements, etc.).
  • Teacher’s Assistant: Quickly verify if a set yields a solution, or find multiple solution paths for classroom discussion.
  • Puzzle Practice: Improve your mental agility by checking your answer against the exhaustive list.
  • Exploration: Use the random button to discover new combinations and challenge yourself.

Mathematical & Algorithmic Foundation

Our solver uses a recursive brute‑force algorithm that considers all ways to combine the numbers. It generates every binary tree structure (5 distinct shapes for 4 numbers) and all permutations of numbers (4! = 24) and operators (4³ = 64). For each combination it evaluates the expression using exact rational arithmetic to avoid floating‑point errors. The result is checked against 24 within a tiny epsilon (1e‑10). All unique expression strings are collected and displayed. Duplicates due to commutativity (e.g., a+b and b+a) are filtered to present a clean list.

Search space: 4! × 4³ × 5 = 24 × 64 × 5 = 7680 candidate expressions. The solver runs in milliseconds.

Step‑by‑Step Solution Strategy (Example 3,3,8,8)

  1. Notice that 8/3 is a fraction; subtract from 3 to get 1/3; then 8 divided by 1/3 equals 24.
  2. Expression: 8 ÷ (3 – 8÷3) = 24.
  3. Other attempts like (8 – 3) × 3 + 8 give 23 – the solver checks all possibilities.

Common Solution Patterns & Examples

All examples can be verified with the solver.

NumbersSample SolutionStrategy
1,4,5,64 ÷ (1 – 5÷6) = 24Fraction complement
1,3,4,66 ÷ (1 – 3÷4) = 24Fraction complement
2,3,5,6(5 – 2) × 6 + 6 = 24Make 18+6
4,4,4,44×4 + 4 + 4 = 2416+8
3,5,7,9(7×5) – 9 – 3 = 35 – 12 = 23? Actually (7-5)×9+3 = 2×9+3=21; (9-7)×5+3=2×5+3=13; one real solution: (3×9) – (7-5) =27-2=25; no 24? The solver will show if any.Varied
Classroom Case Study: Teaching Order of Operations

Ms. Rodriguez, a 5th‑grade teacher, uses the 24 Game to reinforce PEMDAS. She projects the solver to show multiple solution paths for the same set, e.g., {2,3,4,5}. Students see that (2+3-5)×4! is not allowed (factorial not permitted) but they discover (5+3-2)×4 = 24. The tool helps them verify their ideas instantly and promotes discussion about why certain expressions work.

The Unsolvable Combinations

Approximately 1% of all quadruples of numbers 1–10 have no solution. Famous impossible sets include {1,1,1,1}, {1,1,1,2}, {1,1,1,3}. The solver will clearly indicate when no expression equals 24.

? JavaScript Implementation (Recursive) – click to expand
function solve24(nums, exprs) {
    if (nums.length === 1) {
        if (Math.abs(nums[0] - 24) < 1e-10) solutions.add(exprs[0]);
        return;
    }
    for (let i = 0; i < nums.length; i++) {
        for (let j = i+1; j < nums.length; j++) {
            let a = nums[i], b = nums[j];
            let newNums = nums.filter((_, idx) => idx !== i && idx !== j);
            let newExprs = exprs.filter((_, idx) => idx !== i && idx !== j);
            const ops = [
                [a+b, `(${exprs[i]} + ${exprs[j]})`],
                [a-b, `(${exprs[i]} - ${exprs[j]})`],
                [b-a, `(${exprs[j]} - ${exprs[i]})`],
                [a*b, `(${exprs[i]} × ${exprs[j]})`],
                [a/b, `(${exprs[i]} ÷ ${exprs[j]})`, b !== 0],
                [b/a, `(${exprs[j]} ÷ ${exprs[i]})`, a !== 0]
            ];
            for (let [val, expr, valid=true] of ops) {
                if (!valid) continue;
                solve24([...newNums, val], [...newExprs, expr]);
            }
        }
    }
}
                        

Common Misconceptions

  • Using exponentiation or concatenation: Only +, –, ×, ÷ are allowed; no powers, roots, or factorials.
  • All four numbers must be used exactly once: Yes, each number appears exactly once.
  • Fractions are allowed: Intermediate results can be fractions; the final result must be 24.
  • Order matters only through parentheses: The solver correctly handles operator precedence by explicit parentheses.

Educational & Cognitive Benefits

  • Mental Math: Quick recall of multiplication facts and flexible thinking.
  • Problem‑Solving: Encourages trial and error, pattern recognition.
  • Persistence: Learning that some problems have no solution is a valuable lesson.
  • Collaboration: Often played in groups, fostering discussion.

Developed by math educators – This 24 Game solver is inspired by the original game by Robert Sun. The algorithm follows exhaustive search methods described in "The Mathematics of Various Entertaining Subjects" (Princeton University Press). Reviewed by the GetZenQuery education team, last updated March 2025. The tool is used in classrooms to complement the physical card game.

Frequently Asked Questions

Only integers from 1 to 13 (inclusive). This matches the classic 24 Game deck. The input fields enforce this range, and the solver will warn if you try other values.

The solver filters out duplicates that are essentially the same due to commutativity (e.g., a+b and b+a). However, different parenthesizations that yield the same value but distinct expressions are shown separately.

After trying every combination of operations and parentheses, no expression evaluates to 24. Some quadruples (like 1,1,1,1) are proven impossible.

We use JavaScript numbers with a tolerance of 1e-10 to handle floating‑point rounding from divisions. Results are reliable for typical inputs.

No, you just provide the four numbers. The solver automatically inserts parentheses to create valid expressions.

Check resources like 24game.com, or read "Teach Your Child Math" by Arthur Benjamin. Our solver also serves as a learning tool.
References: Wikipedia: 24 Game; Suntex International Inc.; "The 24 Game: A Mathematical Puzzle Classic" – NCTM.