2=(4/4) + (4/4)
3=(4 + 4 + 4)/4
4=(4-4)*4 + 4
The answer depends on what mathematical symbols are allowed. My answers are listed at the end. At the time I writing this (March 2007), these are more definitive than anything I can find on the Internet.
I use the following impurity (I stole this term from David Wheeler's web site) levels to denote the different mathematical symbols that are allowed:
The different levels are arbitrary and they are based on when I was exposed to the particular symbol. Other Internet sites use similar concepts. I believe that all symbols up through level 4 should be allowed. Personally, I would allow sub-factorials, but not gamma functions; however, the concensus of various web sites is to allow gamma functions, but not sub-factorials. My rationale is simple: these were all symbols I was introduced to at high school math level, even the sub-factorial. I was never exposed to the gamma function at high school maths, or even the first year of college maths, but perhaps I was sleeping that day.
There is a good argument for allowing triangle numbers, however there is not a common mathematical symbol for it. Some would argue that the Greek Sigma character (Σ) or Delta (Δ) is the common mathematical symbol. If you allow a symbol that is the product of all numbers less than or equal to n (n!), then how can you exclude a symbol that is the sum of all numbers less than or equal to n?
I do not allow unusual decimal point numbers. I use .4=2/5, .4R=4/9, and sqrt(.4R)=2/3. I do not allow anything that starts ".(", for example I do not allow .(4!) which is supposed to represent .24.
I do not allow the percent character. Expressions such as sqrt(4%) look alien to me - I do not know what number this is supposed to represent. I can almost see using 4%(something), but not x/4%.
There are some interesting symbols that we could add to the problem
I do not allow binary operators such as XOR, OR, AND as these also seem unusual when working in a decimal system.
I've seen different reports on the original history of the problem. One site states that it appears in "The Schoolmaster's Assistant: Being a Compendium of Arithmetic Both Practical and Theoretical" (first edition c. 1744), a popular textbook by the English schoolteacher and cleric Thomas Dilworth (d. 1780) (reference). According to this site, the allowed operations correspond to those allowed up to (my) level 3 (unsure if the arbitrary root power is allowed).
Other sites (Wikipedia) claim the first reference is in "Mathematical Recreations and Essays" by W. W. Rouse Ball published in 1892.
David uses the following "impurity levels":
His level 4 corresponds with my level 4a. He only lists numbers up to 40000. My level 4a includes all of the numbers that he has in level 4. The first ten numbers that he uses level 5 or above are 197, 379, 395, 397, 413, 427, 437, 461, 467, 493. As an example, I can create some of these numbers using (his) level 4 operators.
I also have the following numbers in my level 4a that David does NOT have in his "definitive" list:
There are many more - I counted over 140 separate numbers under 40,000 that I have an entry for that David does not.
These results show the lowest number using up to four four's. The number of fours column shows the number of entries that use that number of fours. The highest number I track is arbitrary - once you allow the ! symbol then an infinite number of numbers can be created.
|Level||Symbols allowed||Results||Number of 4s||Ten lowest numbers that are not listed|
|0||+-*/||Level 0 Results||1||4||12||30||47||13 14 18 19 21 22 23 25 26 27|
|1||sqrt(), ".4", ".4R"||Level 1 Results||2||10||49||352||413||31 51 57 58 59 61 71 73 74 76|
|2||n!||Level 2 Results||3||33||318||3502||3856||113 157 163 166 167 171 173 185 187 191|
|3||.4sqrt()||Level 3 Results||3||34||323||3561||3921||113 157 163 166 167 171 173 185 187 191|
|4a||gamma(n)||Level 4a Results (0.8Mb)||7||87||1232||18081||19407||197 395 397 413 427 437 467 493 499 501|
|4b||!n but not gamma(n)||Level 4b Results (3.4Mb)
gzip version (0.8Mb)
|11||189||3840||79697||83737||878 881 893 917 943 946 947 1019 1109 1139|
|5||gamma(n) and |
|Level 5 Results (6.1Mb)
gzip version (1.4Mb)
|13||263||5985||139531||145792||878 893 947 1139 1207 1213 1214 1217 1243 1267|
|6||tri(n)||Too big (426Mb)||35||2436||157514||8665171||8825156||13117 15677 17077 18689 19013 19343 19753 20443 21314 22073|
The format of the results file may be a little difficult to read. The first entry is the number represented with the fewest number of fours and the impurity level. The second part of the entry is the number represented with four fours at the lowest impurity level. I have kept everything in text files. Also, it keeps the file shorter to represent the number using the intermediate number. For example, 1457 = 1458 - 1. To find the actual representation using fours, you have to look up the number 1458 and the number 1. 1458 = 2 * 729. Eventually you get to 1457 = sqrt(4)*(sqrt(sqrt(sqrt((!4)^4!)))) - !(sqrt(4)).
The results in level 5 assume that impurity level 4 is the gamma function and impurity level 5 is the sub-factorial.
The interesting programming challenges were working with large numbers and keeping the code compact. The other interesting aspect was the size of the data. I did the work on a 512Mb machine - lots of tricks to keep the program reasonably fast. If you start working on this, suggest you always use fractions for computation (when comparing two numbers, you have to consider .4 and .4R). Also suggest using a good "back-end" to store all of the data that is being generated.
It is possible that I have some of the numbers wrong (I hope not, but anything is possible). In some cases (particularly when dealing with fractions), I hard-coded the fraction in the code. Some errors crept in to my first attempts at this because of integer wrap-around - I think I now have appropriate checks in the code for this but it's possible I have missed one. It is also possible that I have the correct function in the code, but when outputing the function, I failed to correct some cut/paste errors. If you notice anything that is wrong, please let me know so I can correct it.
As of today, this is the most complete list on the Internet.
If you need to know the result with, or without, a particular function, and I've got enough time, then I might be able to create the answer.
Last updated: February 4, 2017