Division and Greatest common divisor
Author: Zademn
Introduction
Two of the skills a cryptographer must master are:
Knowing his way and being comfortable to work with numbers.
Understanding and manipulating abstract objects.
This chapter of fundamentals proposes to prepare you for understanding the basics of number theory and abstract algebra .We will start with the most basic concepts such as division and build up knowledge until you, future cryptographer, are able to follow and understand the proofs and intricacies of the cryptosystems that make our everyday life secure.
We will provide examples and snippets of code and be sure to play with them. If math is not your strongest suit, we highly suggest to pause and ponder for each concept and take it slow.
For the math-savy people we cover advanced topics in specific chapters on the subjects of number theory and group theory.
So what are we waiting for? Let's jump right in!
Division
Let be the set denoting the integers.
Definition - Divisibility
For we say that divides if there is some such that
Notation:
Example
For we have because we can find such that .
Properties
and implies
Example: Let and
and . We can find such that
and implies
if and then
Definition - Division with remainder
Let with ,
There exists unique such that and
is called the quotient and the remainder
Examples:
To find python offers us the
divmod()
function that takes as arguments
If we want to find only the quotient we can use the
//
operatorIf we want to find the remainder we can use the modulo
%
operator
Exercises:
Now it's your turn! Play with the proprieties of the division in Python and see if they hold.
Greatest common divisor
Definition
Let be 2 integers. The greatest common divisor is the largest integer such that and
Notation:
Examples:
Remark:
for all other common divisors of we have
Things to think about
What can we say about numbers with ? How are their divisors?
Last updated