I finally understood recursion... by writing a bad calculator

Guide

So I’ve been banging my head against recursion for weeks. All the “factorial” examples never clicked for me.

Then yesterday, I tried to make a basic calculator that could handle parentheses and order of operations. Didn’t even plan to use recursion—but suddenly I needed to evaluate nested expressions. Boom. Recursion actually made sense.

The code’s a mess. I’m sure it’s not efficient. But I finally get the concept now.

Just wanted to say to anyone struggling: sometimes you don’t learn recursion by studying it—you learn it when you randomly need it. Stick with it

Posted Jul 17, 2025, 8:49 AM UTC

71
Loading comments…