Sometimes when working with large numbers, it might be faster if results are modded after each calculation. To use it you just add "mod <integer>" after the expression. Example:
2^(5!) * 3^(6!) mod 5You can calculate the inverses of numbers mod some integer by just using rational numbers (of course the inverse has to exist). Examples:
10^-1 mod 101 1/10 mod 101You can also do modular evaluation with matrices including taking inverses, powers and dividing. Example:
A = [1,2;3,4] B = A^-1 mod 5 A*B mod 5This should yield the identity matrix as B will be the inverse of A mod 5.
Some functions such as
sqrt
or
log
work in a different way when in modulo mode. These will then work like their
discrete versions working within the ring of integers you selected. For
example:
genius> sqrt(4) mod 7 = [2 5] genius> 2*2 mod 7 = 4
sqrt
will actually return all the possible square
roots.