Note: For the sake of clarity I'll probably write things you already know. It's just as much to eliminate communication errors as it is for me to keep track of what the fuck I'm even talking about. It does not imply any kind of judgment of what I assume about you :)
Here's the math behind gears and how they are used to efficiently rotate wheels. The same principles underlie how cars work but the mechanisms are