25
$\begingroup$

Write 24 using the four numbers 1, 3, 4, 6 and basic arithmetic.

Explanations:

  1. The given are numbers, not digits, so you can't group them using decimal notation. For example, you can't create the number 6431.

  2. Only one occurrence of each number is allowed. For example, you can't write 24 = 6 + 6 + 6 + 6.

  3. All numbers have to be used.

  4. Basic arithmetic means only the 4 operations: +, -, x, /. Also parentheses (...) are allowed to set the order of operations.

$\endgroup$
5
  • $\begingroup$ I have a feeling the solution has something to do with decimals and not just integers, but that's as far as I've gotten so far. $\endgroup$
    – Doorknob
    Commented Jun 9, 2014 at 16:45
  • $\begingroup$ I had this puzzle once, when I was in grade 9 at a math camp. $\endgroup$
    – user88
    Commented Jun 9, 2014 at 17:49
  • 1
    $\begingroup$ @klm123, Why not just bruteforce it? $\endgroup$
    – Pacerier
    Commented Jun 9, 2014 at 22:12
  • $\begingroup$ Is there a way to generalize this problem? By the way, I've seen this question asked in Hacking:the art of exploitation $\endgroup$ Commented Jun 25, 2014 at 16:53
  • $\begingroup$ @G.T.R, I have no idea what do you mean by generalization of such type of problem, which have unique and unusual (in some psychological sense) answer. $\endgroup$
    – klm123
    Commented Jun 25, 2014 at 18:35

3 Answers 3

42
$\begingroup$

$\dfrac{6}{1 - \frac{3}{4}}$

This simplifies to $\frac{6}{1/4}$, which becomes $6 \cdot 4$, which becomes $24$.

$\endgroup$
3
  • $\begingroup$ So there's a 5th rule about order of operations? $\endgroup$
    – Jason
    Commented Jun 9, 2014 at 23:46
  • 1
    $\begingroup$ parentheses are used to define order of operations :-) $\endgroup$
    – mau
    Commented Jun 10, 2014 at 13:53
  • 1
    $\begingroup$ @Jason, that's a valid question. I corrected the condition to allow them explicitly. $\endgroup$
    – klm123
    Commented Jun 10, 2014 at 17:33
15
$\begingroup$

This boils down to the same solution as Kevin's, but uses Reverse Polish notation.

6   1   3   4   /   -   /   =>   24

Notice the elegance of the notation, the lack of brackets, the lack of different sized fonts, the lack of confusing latex markup to write it, the sheer incomprehensibility of what's actually going on, ... uhm, yeah, apart from that, though.

The contents of the stack at each step:

The operations and the contents of the stack at each step

$\endgroup$
1
  • 3
    $\begingroup$ Excellent answer, but you need to spell out the point: this makes the problem amenable and optimal for recursion without having to add parentheses and worry about nested parsing of open-close parentheses. Recursion simply has to consider all legal string combinations of numbers and the four arithmetic operators. (Order is obviously significant) $\endgroup$
    – smci
    Commented Jun 4, 2017 at 23:54
1
$\begingroup$

$6 \times 4 - 3 - 1$
If numbers are in the octal base.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.