Factorial Calculator

by Vafanasj in Circuits > Microcontrollers

316 Views, 1 Favorites, 0 Comments

Factorial Calculator

20210804_124119.jpg
This is a calculator anybody could use to calculate the factorial of any non-negative number

Supplies

A micro:bit
A phone or computer
Anything that you can use to upload code to a micro:bit

The Code for the Micro:bit

download (1).png

This is the code for the factorial calculator, which uses a 2-button system to change the number you want to factorialize:

https://makecode.microbit.org/_MzaVWKV31

The Instructions

download (2).png

Instructions: If you press button A, you increase the number you want to factorialize by 1. If you press button B, the opposite happens. If you press button A and B together, you factorialize the number. If you press the reset button on the back of the micro:bit, you reset the program back to the start.

Setting Up

download.png

To set up your micro:bit, you can go ahead and plug it into a computer so that you can flash your program from the online editor to your micro:bit or plug the micro:bit into a wall, use Bluetooth on your phone to connect to it and use the micro:bit app to send programs.