Let's look at modular arithmetic. The first function we'll look at is the quotient and remainder function.
x//y returns the quotient of x and y.
x%y returns the remainder.
|
|
Let's look at modular arithmetic. For a more complete tutorial, see:
buzzard.ups.edu/sage/sage-group-theory-primer.pdf
The first function we'll look at is the quotient and remainder function.
x//y returns the quotient of x and y.
x%y returns the remainder.
|
|
We can also do the Euler phi function.
|
|
And a prime test.
|
|
Here is an example of some more advanced modular arithmetic. If we wish to deal with Z/nZ we use the command
IntegerModRing(n).
In the example below, we'll use integers mod 97. We'll also demonstrate how to take the modulus and a test to see if a number is square:
For a number n:
n.modulus() returns the modulus.
n.is_square() returns 'True' or 'False'.
|
|
|
|