Given the four arithmetic operators {+, -, *, /} and four times the number 4, that is {4,4,4,4}, I would like to find a way to count how many arithmetic formula I am able to construct.

I find difficult to express my thoughts, but I would like to build an algorithm in order to find every formulas as in that page :


Please look at the upper right corner : la page 4 (c'est fini)

My goal is to find a way to generalize this, that is :

To find all the natural numbers we can build by combining those arithemtic operators and given 1, 2, 3, 4, ..., n times the number n.

Many thanks for any help...

  • 31
  • 1
  • 1
    You may be interested in [this tool](http://math.stackexchange.com/questions/92230/proving-you-cant-make-2011-out-of-1-2-3-4-nice-twist-on-the-usual/93188#93188) and [this question](http://math.stackexchange.com/questions/93729/how-many-fours-are-needed-to-represent-numbers-up-to-n). – David Bevan Mar 15 '13 at 14:38

1 Answers1


The answer will depend on what you mean by distinct formulae. Here's one simple approach.

Let $S_k$ be the set of formulae that contain $k$ binary operations.

Then $S_1=\{4\}$, and for $k\geqslant1$,

$$S_{k+1}\;=\;\bigcup_{i=1}^k\Big\{(\alpha\,op\,\beta)\::\:\alpha\in S_i,\,\beta\in S_{k+1-i},\, op\in\{+,-,\times,\div\}\Big\}.$$

If you don't want to distinguish between $(4+4)+4$ and $4+(4+4)$, then you'll have to keep track of the last operation.

David Bevan
  • 5,812
  • 2
  • 16
  • 31