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 Z={…,−1,0,1,2,3…}be the set denoting the integers.
Definition - Divisibility
For a,b,∈Zwe say that adivides bif there is some k∈Zsuch that a⋅k=b
Notation: a∣b
Example
For a=2,b=6 we have 2∣6 because we can find k=3such that 6=2⋅3.
Properties
a∣a, 1∣a and a∣0
a∣b and a∣c implies a∣(bu+cv) ∀u,v,∈Z
Example: Let b=6,u=5 and c=9,v=2
3∣6 and 3∣9⇒3∣(6⋅5+9⋅2)⟺3∣48 . We can find k=16such that 48=3⋅16
a∣b and b∣c implies a∣c
if a∣band b∣a then a=±b
Definition - Division with remainder
Let a,b∈Zwith b≥1,
There exists unique q,r∈Zsuch that a=bq+rand 0≤r<b
q is called the quotient and r the remainder
Examples:
To find q,r python offers us the
divmod()function that takes a,bas arguments
If we want to find only the quotient q we can use the
//operatorIf we want to find the remainder r 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 a,b∈Z be 2 integers. The greatest common divisor is the largest integer d∈Zsuch that d∣aand d∣b
Notation: gcd(a,b)=d
Examples:
Remark:
for all other common divisors c of a,bwe have c∣d
Things to think about
What can we say about numbersa,b with gcd(a,b)=1? How are their divisors?
Last updated
Was this helpful?