Quick Post: Modulus in BASIC 2 without a cartridge

Quick Post: Modulus in BASIC 2 without a cartridge

I posted this on Twitter a few weeks ago, but a young lady has been exploring programming in Python and also with Commodore BASIC which is pretty neato. She's 11 and asked if there was a way to do modulo functions on Commodore BASIC because she's using her Dad's VIC-20 and Simon's BASIC is obviously not available for the VIC-20.

The answer is pretty simple and will actually work in most programming languages.

If we wanted to do A mod B (or A%B in a lot of newer programming languages) we can do it in one line. We're really just looking for the remainder of a division that we'll call R

10 A=10:B=5
20 R=A-INT(A/B)*B
30 PRINT "REMAINDER(MOD) IS:" R

Miss Lisa is way beyond this at the moment and asking all sorts of great questions of her Dad. I'm glad I could be a small part of her journey.