Mathematical Cryptography Calculator

Basic Four Functions & Modular Arithmetic

Type numbers in the X and Y boxes and press the button next to the desired operation to display the result in the Z box. You can store intermediate values by clicking the button to move them into or out of the W register. Enter a nonzero number for the modulus m if you want all computations to be done modulo m. There is a running history of your calculations at the bottom of the page.

Warning: This calculator uses ordinary JavaScript arithmetic. Numbers larger than the word size may overflow and/or wrap without warning, so be careful when using large numbers.

X  = 
Y  = 

Basic Operations
Z = X + Y Z = X - Y
Z = X * Y Z = [X / Y]
Z = X mod Y
Move Values Between Registers
  X ← Z   Y ← Z   X ↔ Y   Z ↔ W
GCD's and Modular Arithmetic
Z = gcd(X,Y) Z = Extended gcd(X,Y)
Z = X-1 (mod m) Z = XY (mod m)

Z  = 
W  = 

Modulus m  = 

Return to the Math 158 Home Page

Software for use by students taking Math 158 at Brown University and for use with the book An Introduction to Mathematical Cryptography by Jeffrey Hoffstein, Jill Pipher, and Joseph H. Silverman. Software © 2004 by J.H. Silverman.