# The Case of the Miscalculating Calculator

At the Arithmetic Company, to try and cut down labor costs the administration commissioned a calculator to be made. The calculator was produced, and in the quality control division was tested with the following values:

20 + 3 = 23
5 + 15 = 20
7 + 9 + 9 = 25
28 - 22 + 2 = 8
33 - 20 + 4 = 17
71 + 5 - 75 = 1
30 + 19 - 5 = 44
45 + 36 - 23 = 58


Finding all the results satisfactory they put the calculator to use. The first client requested various sums of 2, and using the calculator, was given the following list:

2 + 2 = 85
2 + 2 + 2 = 150
2 + 2 + 2 + 2 = 152
2 + 2 + 2 + 2 + 2 = 232
2 + 2 + 2 + 2 + 2 + 2 = 1114
2 + 2 + 2 + 2 + 2 + 2 + 2 = 1167
2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 = 2227
2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 = 17727
2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 = 24727


The next client requests some consecutive sequences and was given:

1 + 2 + 3 + 4 = 130
5 + 6 + 7 + 8 = 130
9 + 10 + 11 + 12 = 188
13 + 14 + 15 + 16 = 1216
17 + 18 + 19 + 20 = 1157


Finally the last client requests just one sum and is given:

1 + 1 = ERROR


The next day they received many complaints from their clients, and decide to bring in you, their best analyst, to figure out what the calculator is doing. Your job is to find the rules that the determine the calculator's output as well as one example sum (not listed above) so that your method can be tested.

Bonus: What does the calculator output when given 1×1 ?

People may ask any number of additional sums to the calculator in the chat room http://chat.stackexchange.com/rooms/22378/sum-requests:

0 + 0 = ERROR
1 + 2 = ERROR
1 - 3 = ERROR
2 - 7 = ERROR
3 + 3 = ERROR
4 + 4 = ERROR
5 + 19 = ERROR
19 + 5 = ERROR
76 - 75 = ERROR
130 - 85 = ERROR
1 - 2 + 3 + 4 = ERROR
2 + 2 - 2 = 2
15 = 7
15 + 5 = 20
18 = 18
19 = 19
7 + 40 = 25
29 = 25
13 + 4 = 26
39 = 35
5 + 5 = 40
9 + 9 = 40
40 = 40
49 - 5 = 40
5 + 5 + 5 = 45
49 = 45
59 = 55
6 + 2 = 70
5 + 5 + 5 + 5 = 72
85 = 85
3 + 7 = 91
2 + 85 = 150
85 + 2 = 150
85 + 85 = 152
71 + 5 = 303
45 + 13 = 517


If necessary, I'll provide a new hint for few days the problem remains unsolved.

Hint 1: When inputting solitary numbers into the calculator you get the following results:

0 = 0
1 = 1
2 = 2
3 = 3
4 = 4
5 = 5
6 = 6
7 = 7
8 = 8
9 = 5
10 = 10


Hint 2:

55 + 1 = 35
59 + 1 = 35
65 + 1 = 107
69 + 1 = 107
75 + 1 = 303
79 + 1 = 303


Hint 3:

15 + 3 = 91
19 + 3 = 35

• That calculator seems pretty messed up. I would fire the whole team and reprogram it myself – Seb Apr 1 '15 at 18:52
• @Seb But think of the sunk costs! – KSab Apr 1 '15 at 19:22
• Damn, I tried to calculate the estimated profits and I keep getting an ERROR – Seb Apr 1 '15 at 19:43
• I believe more hints are necessary. I wrote an program and evaluated more than 3.5 billion break downs composing of +, -, *, /, mod, biggest and smallest operations. I'm likely missing something. – kevin Apr 4 '15 at 4:13
• @KSab Can we get a hint that isn't just another example operation? – Engineer Toast May 1 '15 at 16:39

It took over a year, but it is solved!

The calculator works by converting each number into its english representation (1 --> "one"), and then converting the word back into a number using the system of English Gematria. Operators such as plus and minus work normally. The answer to each equation is the smallest number whose Gematria value matches the left hand side of the equation, or ERROR if no such number exists.

Example. 2 + 2 = 85 because "two" = 348 and "eighty-five" = 696 which is 348 + 348.

Example. 1 + 1 = ERROR because "one" = 204 and there is no number whose Gematria value is 408.

Here are some example Gematria values:

zero       635
one        204
two        348
three      336
four       360
five       252
six        312
seven      390
eight      300
nine       252 = five

fifteen    390 = seven
nineteen   516
twenty     642
forty      504 = five + five
eightyfive 696 = two + two


The answer to the bonus, 1x1, is the number whose Gematria value is equal to 204 * 204 = 41616. This would be a staggeringly huge number and I can't calculate it unless I make a program for it. Maybe someone else can?

EDIT: As suggested in the comments, the intended solution is to convert each letter into a number value (a=1, b=2, ...). Gematria is the same thing except the values are multiplied by 6, so (a=6, b=12, ...). For addition and subtraction, there is no difference.

But for the bonus, the intended solution is 1x1 = "one" x "one" = 34 x 34 = a number whose letter value is 1156, where a=1, b=2, etc. Still a large number, but much more solvable.

• Wow, the Gematria. That's something I never would have thought of. – Joe Z. Jun 16 '16 at 3:35
• Is that just the sum of the letters (using a=1 b=2 etc.) multiplied by six? – f'' Jun 16 '16 at 3:41
• Wow, I have to admit that quite awhile ago I had stopped updating this, having become very busy in my personal life, I certainly didn't expect someone to answer it after all this time! I am both impressed, and incredibly happy that someone figured it out (I worried it was too hard and/or obscure, and perhaps it was considering how long it took :\ ) By the way, it was only intended to be the sum, as the multiplication by 6 indeed does not effect the result. – KSab Jun 16 '16 at 3:56
• The smallest solution for 1x1 seems to be 1121272777, or one billion one hundred twenty-one million two hundred seventy-two thousand seven hundred seventy-seven. (Not sure whether there should be "and"s in between, though, e.g. one hundred and seventy-seven, which would make this solution invalid.) – M Oehm Jun 16 '16 at 10:40
• @MOehm Seeing as "seventy-one" + "five" = "three hundred three" and "two"+"two"+"two" = "one hundred fifty", I don't believe "and"s are included. – McMagister Jun 16 '16 at 14:16

This is not intended to be an answer. The content is simply too involved for a comment. This may all be useless.

First, here's a little VBA UDF you can pop into Excel to have it evaluate the formula. If you plug in the whole formula as an equality such as they are given in the examples, it'll return TRUE or FALSE. If you plug in just one side of the formula, it'll return the solution.

Public Function eval(s As Range) As String
eval = Application.Evaluate(s.Value)
End Function


Put it in a module and call it in a cell with a formula like =eval(A1). This is probably the only piece of this posting that'll be helpful.

## Regarding the Sums of Twos

The answers for the examples that are all sums of twos show a pattern when plotted on a logarithmic scale.

## Regarding the 9=5 Example

As of the time of this posting, there are 72 example formulas given.

24 / 72 evaluate as true on a normal calculator.

28 / 72 evaluate as true if you replace all the 9s with 5s

There are 6 that are true originally but become false if you replace the 9s and 2 that are true but become false.

The examples in Hint 2 become 3 unique examples with each repeated twice if you replace the 9s with 5s.

The calculator may or may not interpret every 9 keypress as a 5

The only answers with a 9 in them are 19=19 and 3 + 7 = 91

## Regarding the ERROR Values

I think the key is in the errors. What kind of logic could dictate that 0+0=ERR and 1+1=ERR? It's not just a simple operator substitution here. There are several more examples of the format A+B=ERR and I have yet to find something that fits them. I feel like there's something key here but I can't grasp it.

• And all answer seems to respect commutativity of operators – Seb Apr 3 '15 at 1:50
• Nice data analysis, but I don't think that's really a pattern! Also, if the ERR isn't caused by a division by 0, it could be the result of an iterative algorithm that went in loop. – leoll2 Apr 3 '15 at 9:02
• @leoll2 I see a pattern in the rate of change. Start from the 2nd point (150) and the slope of each 3 sections follows the pattern ABC where C > B and A starts off at near 0 and increases each time. – Engineer Toast Apr 3 '15 at 12:02
• The errors could also be negative numbers. It never displays a negative result in the examples... – Falco Apr 5 '15 at 18:53

For the bonus question, we can determine that we do not need to use the word "and" in our conversions to text, as it's given that 2 + 85 = 150, and this requires 150 to be spelled "one hundred fifty".

Running a program to find a number that evaluates to "one" * "one" = 34 * 34 = 1156 gives 1,121,272,777, or "one billion one hundred twenty-one million two hundred seventy-two thousand seven hundred seventy-seven".

If we did require the word "and" in the numbers, the answer to 1 * 1 would be 222,274,777, or "two hundred and twenty-two million two hundred and seventy-four thousand seven hundred and seventy-seven".

• 107 does not need to be spelled out, it is the value of "twenty". Besides, "two"+"two"+"two" = "one hundred fifty", – McMagister Jun 16 '16 at 14:10
• Hm, I suppose I got a little lost in all the number-text conversions. Very well, I'll run the program again (without "and") and update my answer accordingly. – Scepheo Jun 16 '16 at 14:23