Code for Two-Button Calculator

Published by


A two-button calculator can only perform two operations (like multiply by two and add five). The Global Math Project is a wonderful resource for math learning and play and has a great resource for two-button problems in this Global Math Project PDF. Another variation of this sort of problem is done in this fun TED-Ed Riddle.

There was a two-button calculator request on twitter, and since I can’t resist playing around, I created one. This could be modified to have more variety in problems and negative numbers, roots or exponents if wanted. It’s basic.

Below is the code in CodePen. Feel free to send me a request for embed code, changes, or take it and modify. The console will have solutions if you run the code in CodePen or p5js. If you need a present mode for students, here it is.

See the Pen TwoButtonCalculator by Sophia (@fractalkitty) on CodePen.

Leave a Reply

Previous Post
Next Post