I added the modular arithmetic and helper functions.
Added script tag in order to view JS code in console.