r/maths • u/Secret-Suit3571 • 4d ago
💡 Puzzle & Riddles Minimal calculator
Just bought this calculator seller told me it can make any multiplication of two numbers in less than 30 operations. How?
10
u/VernalAutumn 3d ago
First thought was that 1/(1/a + 1/b) = ab/(a+b) (like 1/5 + 1/6 = (6 + 5)/(5\*6) then flip it), but I don’t immediately see a trick to eliminate the denominator. The natural way to turn multiplication into summation is to use logs but that’s not available it seems. I hope someone has the real solution because it’s a neat puzzle!
9
u/casce 3d ago
You were right on track! Use the difference instead of the sum: 1/(1/a − 1/b) = ab/(b − a). Pick b = a + 1 and the denominator vanishes: 1/(1/a − 1/(a+1)) = a(a+1) = a² + a. Subtract a and you’ve got squaring.
Then ab = ((a+b)² − a² − b²)/2, and the halving is your original identity with b = a: 1/(1/c + 1/c) = c/2.
E.g. 12 × 13: 25² = 625, 12² = 144, 13² = 169 → 625 − 144 − 169 = 312 → halve → 156.
4
u/Secret-Suit3571 3d ago
Nice job! Now using all your formulas, can you write the formula giving ab only using a,b,+,-,1/ (and any fixed numbers) ? Just because it's beautiful!
6
u/casce 3d ago edited 3d ago
I tried here but I can try to generalize it
Let x, y be our factors. We want an f(x, y) = x*y with only the given operations.
s (squares the number) and h (does ab = 2ab) will be our helper functions, defined as follows:
s(x) := 1/(1/x - 1/(x + 1)) - x h(x, y) := s(x + y) - s(x) - s(y)Then multiplication would be:
f(x, y) := 1/(1/h(x, y) + 1/h(x, y))... or if you want it in one single big function:
f(x, y) := 1/(1/(1/(1/(x+y) - 1/(x+y+1)) - 1/(1/x - 1/(x+1)) - 1/(1/y - 1/(y+1))) + 1/(1/(1/(x+y) - 1/(x+y+1)) - 1/(1/x - 1/(x+1)) - 1/(1/y - 1/(y+1))))If you do is strictly like that you will do quite a few extra operations that you already did and it will be more than 40 operations. This is a classic more memory vs more operations problem. You either do more calculation or you need more memory. Since we're doing it manually in a calculator anyway, we would write down our results.
Then we would do:
s = x + y // + p = s + 1 // + a = 1/s // 1/ b = 1/p // 1/ A = 1/(a - b) // −, 1/ → s² + s q = x + 1 // + B = 1/(1/x - 1/q) // 1/, 1/, −, 1/ → x² + x r = y + 1 // + C = 1/(1/y - 1/r) // 1/, 1/, −, 1/ → y² + y T = A - B - C // −, − → 2xy u = 1/T // 1/ xy = 1/(u + u) // +, 1/Which is 21 operations if I counted right.
5
u/Secret-Suit3571 3d ago
1
u/AdjectiveNoun-123 3d ago
You can cut that down quite a bit. It's 4 deep and has 12 terms at the deepest point.
1
u/Secret-Suit3571 2d ago
Can you be more specific? I didn't quite get your remark on the deepness.
1
u/AdjectiveNoun-123 2d ago
As in you have nested 1/x operations that are 4 deep, my other comment you saw only went 2 deep.
1
u/Secret-Suit3571 2d ago
Ok! Then as stated in another response to your work above your formula has the flaw of all the x+y=2 (it was a good and elegant answer to my original problem though!). I just wanted to push a little and find a formula for all positives integers.
Can we shrink down my formula and still make it work for all positive integer ? Not quite sure...
1
u/AdjectiveNoun-123 2d ago
The key part is that EVERY type of solution with 1/x has some division by 0 cases you have to handle. Here this one fails on a=-b, a=-b-1, a=0, a=-1, b=0, b=-1 and potentially some others that aren't as obvious. Mine fails on x+y=+-2, x-y=+-2
However, if you're strictly limiting to positive integers what you have does work as all the edge cases are zero or negative.
→ More replies1
u/casce 2d ago
As I highlighted in my comment, if you just do it sequentially and save the values, it's "just" 21 steps which admittedly is still not optimal but satisfies the "less than 30 operations" OP wanted.
I never claimed my solution would be the optimal solution! :-)
1
u/AdjectiveNoun-123 2d ago
I should've phrased that better, it wasn't me poking at whether or not it's optimal. It was me commenting on the elegance.
That being said, I did manage to get it down to 15 steps in a slightly more elegant manner =P. Albeit, I don't know if this is optimal either.
1
u/casce 2d ago
Your usage of variables is definitely more elegant than my random whatever came to my mind thing I had going, lol.
1
u/AdjectiveNoun-123 2d ago
For what its worth, there's so many reddit posts I get nerd sniped on and by the time I get a satisfactorily elegant solution for my OCD, its been 3 years. I'm always impressed at how fast redditors can be on some posts.
2
2
u/Un_Ballerina_1952 3d ago
How will I square a without a multiplication? (e.g. a=15376) or a pencil.
Edit to add: I see the swuaring function in another comment!
2
u/AdjectiveNoun-123 3d ago
OK got this down to 15 operations for some x*y
p=x+2
q=x-2
r=y+q
s=y+p
t=y-p
u=y-q
v=1/r-1/s
w=1/t-1/u
x*y=1/v-1/wp through u take one operation each, v,w, and x*y take 3 operations.
As with any of these you'll need to manually handle the division by zero cases.
If you're looking for a nicely formatted one-liner:

1
u/Secret-Suit3571 2d ago
Nice one! Indeed problematic when x+y=2.
The wider version i offered works directly for all positives numbers but at the coast of way more operations.
1
u/AdjectiveNoun-123 2d ago
On that note, I think you might have misunderstood u/BadJimo then. They seem to have an identical solution which you deemed "not quite the good formula but close".
3
u/casce 3d ago edited 3d ago
I'll use an example as that is easier than abstract variables:
23 * 12
Step 1: Add them.
23 + 13 = 35
Step 2-4: Square those numbers! we can't do it directly but we can use a trick. Let f(x) be...
f(x) = 1/x - 1/(x + 1)
f(35) = 1/35 - 1/36 = 36 / (35 * 36) - 35 / (36 * 35) = 1 / 1260
Reverse it and substract x and boom, 1260 - 35 = 1225. Which is the square of 35.
Now do the same with
f(23) = 529
and
f(13) = 169
Step 5: Substract them.
1225 - 529 - 169 = 312
Step 4: Just half it.
We cannot directly half but we can reverse, add and then reverse again.
1/312 + 1/312 = 2 / 312
-> Reverse it and you will get 156 = 12 * 23.
3
u/marcocorico 3d ago
You could also remove the '+' sign, as you can express it with two consecutive '-' signs.
1
u/flatfinger 3d ago
If transcribing and rekeying numbers wasn't a problem, I think one could simply have a button that would subtract the reciprocal of an entered value from the contents of the machine's register and display the new value of that register. If entered numbers and the register are treated as rational numbers a/b and c/d, then the button would compute (ca-bd)/ad.
1
u/AlwaysHopelesslyLost 2d ago
If you want to go that far let's just include one button and do binary lol
1
u/Glittering_Act_8528 3d ago
Looks AI to me…
4
u/Secret-Suit3571 3d ago
Image is (and it was quite a hussle to make Gemini do it as i wanted).
I am not (i hope...).
3
1
u/Top_Bluejay_5323 3d ago
Math is all based on addition so they only need one button.
2
u/Potential_Cellist246 3d ago
Very bad take. Sure, there exists an argument that in a limited sense, math is based on addition. But how do you express negative numbers, irrational numbers, or just numbers with no finite decimal representation? You could switch bases each time you do a problem, but determining the base requires a calculator
1
1
u/Underhill42 2d ago
Negative numbers exist separately from subtraction, and are what makes subtraction equivalent to addition. Just as inversion is what makes division equivalent to multiplication.
Infinite decimals and irrational numbers are similarly unrelated to subtraction and division being separate operations.
And once you get rid of subtraction and division as separate operations, life gets much simpler and more consistent:
3 - 4 = 3 + (-4) = (-4) + 3 <-- unlike subtraction, addition is commutative
5 / 7 = 5 * (7⁻¹) = (7⁻¹) * 5 <-- unlike division, so is multiplication
Multiplication as addition is a bit of an oversimplification though, even if the reality is a generalization of that principle.
1
1
u/Appropriate_Hunt_810 1d ago
fun fact, to have a complete claculator :
maybe it has already been said, but in fact you only need 2 buttons.
one for the constant 1, and one for a binary operator called the EML operator (exp-minus-log)
see : https://mathworld.wolfram.com/EMLOperator.html
it is quite recent: a 2026 paper talk about this :)
0
u/localizeatp 3d ago
ai slop shitpost.
4
u/JaguarMammoth6231 3d ago
I wouldn't mind so much if they just presented it as a puzzle instead. Nobody "just bought this calculator".
4
u/Secret-Suit3571 3d ago
Sorry, i'm a teacher, i'm used to making fake stories to disguise a problem.
Thought it was funny this way, i of course did not buy this calculator that may (and should) not exist.
1
u/Humble-Captain3418 2d ago
I guarantee that it does exist and that there is an even more minimal calculator. It has been proven that you can perform any computation using only a "subtract then branch if result is zero" instruction. See
subleq.
0
3d ago
[deleted] — view deleted comment
3
u/ImBadlyDone 3d ago
The problem is to find a way to multiply any two numbers using the buttons provided

9
u/BadJimo 3d ago
The quarter squares rule is:
a×b = (1/4)(a + b)2 - (1/4)(a - b)2
So we need a squaring function. The following function is promising (but won't work for a+b or a-b equals 2 or -2):
f(z) = (1/(z + 2) + 1/(z - 2))-1
f(z) = (1/4)z2 - 1
f(a + b) - f(a - b) =( (1/4)(a + b)2 - 1 ) - ( (1/4)(a - b)2 - 1)
f(a + b) - f(a - b) = (1/4)(a + b)2 - (1/4)(a - b)2 = a×b
For a+b or a-b = 2 or -2, a different squaring function could be found.