The Magic Codex

24 Game Solver

Four cards, one target: every expression with + − × ÷ and parentheses that makes exactly 24.

Your four numbers (1–13)

    How to use the 24 Game Solver

    1. Enter four numbers from 1 to 13 (card values — aces are 1).
    2. Press Solve — every expression that equals 24 appears, shortest first.
    3. Study the tricks — the fraction solutions are the ones worth memorizing for game night.

    Why fractions matter

    The 24 game's most famous hand is 3, 3, 8, 8, and its only solution is 8/(3−8/3) = 24 — which requires computing 8/3 mid-expression. Solvers that only allow whole-number intermediate steps miss it entirely. This one keeps every intermediate value as an exact fraction (numerator/denominator reduced by gcd), so nothing is lost to rounding and equality with 24 is mathematically certain.

    How it works under the hood

    The search is a recursive pair-combination: pick every unordered pair of remaining values, combine them with each operator — both orders for subtraction and division, one for the commutative addition and multiplication — and recurse on the three values left until a single value remains. Anything equal to exactly 24 (compared as fractions, never floats) is recorded; duplicates collapse and the list caps at 200 expressions, sorted shortest-first. Parentheses print only where precedence demands them.

    How do you play the 24 game?
    Draw four cards (values 1–13, aces count as 1, face cards as 11–13 or 10 by house rules). Using each number exactly once with addition, subtraction, multiplication, division, and parentheses, build an expression that equals 24. First to call out a valid expression wins the round.
    Are fractions allowed in the 24 game?
    In intermediate steps, yes — that's the whole trick of the classic 3, 3, 8, 8 hand: 8/(3−8/3) = 24, and 8/3 is a fraction. The final result must be exactly 24. This solver allows fractions everywhere and checks equality exactly, with no rounding.
    What if my four numbers can't make 24?
    Not every hand works — 1, 1, 1, 1 is impossible, for example. The solver searches every possibility exhaustively, so when it says 'no solution' you can trust it: the hand genuinely can't make 24.
    How does the solver find every solution?
    It recursively combines every pair of numbers with every operator — both orders for subtraction and division — and recurses until one value remains. Arithmetic uses exact fractions, never floating point, so 1/3 stays 1/3 and equality with 24 is exact. Duplicate expressions are collapsed and the list is capped at 200.
    Can each number be used more than once?
    No — the classic rule is each of the four numbers exactly once. Every solution shown here uses each of your four inputs exactly one time.
    Is my input sent anywhere?
    No. The search runs entirely in your browser with JavaScript. Nothing is uploaded, stored, or tracked.

    Need help with this tool?

    Found a bug, or have a suggestion for the codex? Write to us — a real human reads every message.

    [email protected]

    More from the codex