Basic Number Theory

This article gives a brief introduction to the beginning of number theory.

Divisibility

Definition

Let a,b∈Za,b\in\mathbf{Z} and a≠0a\ne 0. If ∃q∈Z\exists q\in\mathbf{Z} such that b=aqb=aq, then bb is said to be divisible by aa, written a∣ba\mid b; the statement that bb is not divisible by aa is written a∤ba\nmid b.

Properties of divisibility:

  • a∣b  ⟺  −a∣b  ⟺  a∣−b  ⟺  ∣a∣∣∣b∣a\mid b\iff-a\mid b\iff a\mid-b\iff|a|\mid|b|
  • a∣b∧b∣c  ⟹  a∣ca\mid b\land b\mid c\implies a\mid c
  • a∣b∧a∣c  ⟺  ∀x,y∈Z,a∣(xb+yc)a\mid b\land a\mid c\iff\forall x,y\in\mathbf{Z}, a\mid(xb+yc)
  • a∣b∧b∣a  ⟹  b=±aa\mid b\land b\mid a\implies b=\pm a
  • Let m≠0m\ne0. Then a∣b  ⟺  ma∣mba\mid b\iff ma\mid mb.
  • Let b≠0b\ne0. Then a∣b  ⟹  ∣a∣≤∣b∣a\mid b\implies|a|\le|b|.
  • Let a≠0,b=qa+ca\ne0,b=qa+c. Then a∣b  ⟺  a∣ca\mid b\iff a\mid c.

Divisors

Definition

If a∣ba\mid b, then bb is called a multiple of aa, and aa is called a divisor of bb.

The number 00 is a multiple of every non-00 integer. For an integer b≠0b\ne0, bb has only finitely many divisors.

Trivial divisors (trivial factors): for an integer b≠0b\ne0, ±1\pm1 and ±b\pm b are the trivial divisors of bb. When b=±1b=\pm1, bb has only two trivial divisors.

For an integer b≠0b\ne 0, the other divisors of bb are called proper divisors (proper factors, nontrivial divisors, or nontrivial factors).

Properties of divisors:

  • Let b≠0b\ne0 be an integer. As dd ranges over all divisors of bb, bd\dfrac{b}{d} also ranges over all divisors of bb.
  • Let b>0b\gt 0 be an integer. As dd ranges over all positive divisors of bb, bd\dfrac{b}{d} also ranges over all positive divisors of bb.

In concrete problems, unless stated otherwise, “divisor” always means “positive divisor.”

Division with Remainder

Remainder

Let a,ba,b be two given integers with a≠0a\ne0, and let dd be a given integer. Then there is a unique pair of integers qq and rr satisfying b=qa+r,d≤r<∣a∣+db=qa+r,d\le r<|a|+d.

For any choice of the integer dd, rr is called a remainder. The statement a∣ba\mid b is equivalent to a∣ra\mid r.

In general, take dd to be 00. Then the equation b=qa+r,0≤r<∣a∣b=qa+r,0\le r<|a| is called division with remainder. Here rr is called the least nonnegative remainder.

There are two other common choices of remainder:

  • Absolute least remainder: take dd to be the negative of half the absolute value of aa. That is, b=qa+r,−∣a∣2≤r<∣a∣−∣a∣2b=qa+r,-\dfrac{|a|}{2}\le r<|a|-\dfrac{|a|}{2}.
  • Least positive remainder: take dd to be 11. That is, b=qa+r,1≤r<∣a∣+1b=qa+r,1\le r<|a|+1.

Division with remainder has only one least nonnegative remainder. Unless stated otherwise, “remainder” always means the least nonnegative remainder.

Properties of remainders:

  • After any integer is divided by a positive integer aa, its remainder is exactly one of the numbers from 00 to (a−1)(a-1); there are aa such numbers.
  • When any aa consecutive integers are divided by the positive integer aa, they produce exactly the aa remainders above. In particular, exactly one of them is divisible by aa.

Greatest Common Divisor and Least Common Multiple

For the definitions of the four terms common divisor, common multiple, greatest common divisor, and least common multiple, see greatest common divisor.

Warning

Some authors consider the greatest common divisor of 00 and 00 undefined, while others generally regard it as 00. The latter convention is used in the C++ STL implementation, which treats the greatest common divisor of 00 and 00 as 001.

The greatest common divisor has the following properties:

  • (a1,…,an)=(∣a1∣,…,∣an∣)(a_1,\dots,a_n)=(|a_1|,\dots,|a_n|);
  • (a,b)=(b,a)(a,b)=(b,a);
  • If a≠0a\ne 0, then (a,0)=(a,a)=∣a∣(a,0)=(a,a)=|a|;
  • (bq+r,b)=(r,b)(bq+r,b)=(r,b);
  • (a1,…,an)=((a1,a2),a3,…,an)(a_1,\dots,a_n)=((a_1,a_2),a_3,\dots,a_n). Consequently, ∀1<k<n−1, (a1,…,an)=((a1,…,ak),(ak+1,…,an))\forall 1<k<n-1,~(a_1,\dots,a_n)=((a_1,\dots,a_k),(a_{k+1},\dots,a_n));
  • For integers not all equal to 00, a1,…,ana_1,\dots,a_n, and a nonzero integer mm, (ma1,…,man)=∣m∣(a1,…,an)(ma_1,\dots,ma_n)=|m|(a_1,\dots,a_n);
  • For integers not all equal to 00, a1,…,ana_1,\dots,a_n, if (a1,…,an)=d(a_1,\dots,a_n)=d, then (a1/d,…,an/d)=1(a_1/d,\dots,a_n/d)=1;
  • (an,bn)=(a,b)n(a^n,b^n)=(a,b)^n.

The greatest common divisor also has the following properties related to coprimality:

  • If b∣acb|ac and (a,b)=1(a,b)=1, then b∣cb\mid c;
  • If b∣cb|c, a∣ca|c, and (a,b)=1(a,b)=1, then ab∣cab\mid c;
  • If (a,b)=1(a,b)=1, then (a,bc)=(a,c)(a,bc)=(a,c);
  • If (ai,bj)=1, ∀1≤i≤n,1≤j≤m(a_i,b_j)=1,~\forall 1\leq i\leq n,1\leq j\leq m, then (∏iai,∏jbj)=1\left(\prod_i a_i,\prod_j b_j\right)=1. In particular, if (a,b)=1(a,b)=1, then (an,bm)=1(a^n,b^m)=1;
  • For integers a1,…,ana_1,\dots,a_n, if ∃v∈Z, ∏iai=vm\exists v\in \mathbf{Z},~\prod_i a_i=v^m, and (ai,aj)=1, ∀i≠j(a_i,a_j)=1,~\forall i\ne j, then ∀1≤i≤n, aim∈Z\forall 1\leq i\leq n,~\sqrt[m]{a_i}\in\mathbf{Z}.

The least common multiple has the following properties:

  • [a1,…,an]=[∣a1∣,…,∣an∣][a_1,\dots,a_n]=[|a_1|,\dots,|a_n|];
  • [a,b]=[b,a][a,b]=[b,a];
  • If a≠0a\ne 0, then [a,1]=[a,a]=∣a∣[a,1]=[a,a]=|a|;
  • If a∣ba\mid b, then [a,b]=∣b∣[a,b]=|b|;
  • [a1,…,an]=[[a1,a2],a3,…,an][a_1,\dots,a_n]=[[a_1,a_2],a_3,\dots,a_n]. Consequently, ∀1<k<n−1, [a1,…,an]=[[a1,…,ak],[ak+1,…,an]]\forall 1<k<n-1,~[a_1,\dots,a_n]=[[a_1,\dots,a_k],[a_{k+1},\dots,a_n]];
  • If ai∣m, ∀1≤i≤na_i\mid m,~\forall 1\leq i\leq n, then [a1,…,an]∣m[a_1,\dots,a_n]\mid m;
  • [ma1,…,man]=∣m∣[a1,…,an][ma_1,\dots,ma_n]=|m|[a_1,\dots,a_n];
  • [a,b,c][ab,bc,ca]=[a,b][b,c][c,a][a,b,c][ab,bc,ca]=[a,b][b,c][c,a];
  • [an,bn]=[a,b]n[a^n,b^n]=[a,b]^n.

The greatest common divisor and least common multiple can be combined to produce many remarkable identities, such as:

  • (a,b)[a,b]=∣ab∣(a,b)[a,b]=|ab|;
  • (ab,bc,ca)[a,b,c]=∣abc∣(ab,bc,ca)[a,b,c]=|abc|;
  • (a,b,c)2(a,b)(b,c)(a,c)=[a,b,c]2[a,b][b,c][a,c]\dfrac{(a,b,c)^2}{(a,b)(b,c)(a,c)}=\dfrac{[a,b,c]^2}{[a,b][b,c][a,c]}.

All these properties can be proved from the definitions or the fundamental theorem of arithmetic. Proofs using the fundamental theorem of arithmetic are easier to understand.

Coprime

Definition

If (a1,a2)=1(a_1,a_2)=1, then a1a_1 and a2a_2 are called coprime (relatively prime).

If (a1,…,ak)=1(a_1,\ldots,a_k)=1, then a1,…,aka_1,\ldots,a_k are called coprime (relatively prime).

Several integers being coprime does not necessarily mean that they are pairwise coprime. For example, 66, 1010, and 1515 are coprime, but no two of them are coprime.

The properties of coprimality and the theory of greatest common divisors lead to Bézout's identity. See Bézout's identity.

Euclidean Algorithm

The Euclidean algorithm, also called Euclid's algorithm, is an algorithm. See greatest common divisor.

Prime and Composite Numbers

Algorithms for primes can be found at primes.

Definition

Let p≠0,±1p\ne0,\pm1 be an integer. If pp has no divisors other than its trivial divisors, then pp is called a prime (irreducible number).

If an integer a≠0,±1a\ne0,\pm 1 and aa is not prime, then aa is called composite.

pp and −p-p are always either both prime or both composite. Unless stated otherwise, “prime” always means a positive prime.

If a factor of an integer is prime, that prime is called a prime factor (prime divisor) of the integer.

Simple properties of primes and composite numbers:

  • An integer greater than 11, denoted aa, is composite if and only if aa can be represented as the product of integers dd and ee ($1<d,e [!note]+ Arithmetic Fundamental Lemma

Let pp be prime. If p∣a1a2p\mid a_1a_2, then at least one of p∣a1p\mid a_1 and p∣a2p\mid a_2 holds.

With a slight modification of the converse of the fundamental arithmetic lemma, we obtain another definition of a prime.

Another Definition of a Prime

For an integer p≠0,±1p\ne 0,\pm 1, if for any integers satisfying p∣a1a2p\mid a_1a_2, namely a1,a2a_1,a_2, either p∣a1p\mid a_1 or p∣a2p\mid a_2 holds, then pp is called prime.

Tip

The motivation for this definition can be found in prime ideals.

Fundamental Theorem of Arithmetic (Unique Factorization Theorem)

Let aa be a positive integer. Then it has a representation:

a=p1p2⋯psa=p_1p_2\cdots p_s

where pj(1≤j≤s)p_j(1\le j\le s) are primes. Moreover, this representation is unique up to order.

Standard Prime Factorization

Combining equal primes in the representation above gives:

a=p1α1p2α2⋯psαs,p1<p2<⋯<psa={p_1}^{\alpha_1}{p_2}^{\alpha_2}\cdots{p_s}^{\alpha_s},p_1<p_2<\cdots<p_s

This is called the standard prime factorization of the positive integer aa.

The fundamental theorem of arithmetic and the fundamental arithmetic lemma are equivalent theorems.

Congruence

Definition

Let m≠0m\ne0 be an integer. If m∣(a−b)m\mid(a-b), then mm is called the modulus (mod), aa is congruent to bb modulo mm, and bb is a residue of aa modulo mm. This is written a≡b(modm)a\equiv b\pmod m.

Otherwise, aa is not congruent to bb modulo mm, and bb is not a residue of aa modulo mm. This is written a≢b(modm)a\not\equiv b\pmod m.

An equality of this kind is called a congruence modulo mm, or simply a congruence.

By the properties of divisibility, the congruence above is also equivalent to a≡b(mod(−m))a\equiv b\pmod{(-m)}.

In what follows, unless stated otherwise, the modulus is always a positive integer.

The bb in the expression is a residue of aa modulo mm, and this concept is exactly the same as a remainder. By restricting the range of bb, we correspondingly obtain the least nonnegative residue, absolute least residue, and least positive residue of aa modulo mm.

Properties of congruences:

  • Congruence is an equivalence relation, that is, it has
    • Reflexivity: a≡a(modm)a\equiv a\pmod m.
    • Symmetry: if a≡b(modm)a\equiv b\pmod m, then b≡a(modm)b\equiv a\pmod m.
    • Transitivity: if a≡b(modm),b≡c(modm)a\equiv b\pmod m,b\equiv c\pmod m, then a≡c(modm)a\equiv c\pmod m.
  • Linear operations: if a,b,c,d∈Z,m∈N∗,a≡b(modm),c≡d(modm)a,b,c,d\in\mathbf{Z},m\in\mathbf{N}^*,a\equiv b\pmod m,c\equiv d\pmod m, then:
    • a±c≡b±d(modm)a\pm c\equiv b\pm d\pmod m.
    • a×c≡b×d(modm)a\times c\equiv b\times d\pmod m.
  • Let f(x)=∑i=0naixif(x)=\sum_{i=0}^n a_ix^i and g(x)=∑i=0nbixig(x)=\sum_{i=0}^n b_ix^i be two polynomials with integer coefficients, let m∈N∗m\in\mathbf{N}^*, and suppose ai≡bi(modm), 0≤i≤na_i\equiv b_i\pmod m,~0\leq i\leq n. Then for every integer xx, f(x)≡g(x)(modm)f(x)\equiv g(x)\pmod m. Consequently, if s≡t(modm)s\equiv t\pmod m, then f(s)≡g(t)(modm)f(s)\equiv g(t)\pmod m.
  • If a,b∈Z,k,m∈N∗,a≡b(modm)a,b\in\mathbf{Z},k,m\in\mathbf{N}^*,a\equiv b\pmod m, then ak≡bk(modmk)ak\equiv bk\pmod{mk}.
  • If a,b∈Z,d,m∈N∗,d∣a,d∣b,d∣ma,b\in\mathbf{Z},d,m\in\mathbf{N}^*,d\mid a,d\mid b,d\mid m, then if a≡b(modm)a\equiv b\pmod m, ad≡bd( mod   md)\dfrac{a}{d}\equiv\dfrac{b}{d}\left(\bmod\;{\dfrac{m}{d}}\right).
  • If a,b∈Z,d,m∈N∗,d∣ma,b\in\mathbf{Z},d,m\in\mathbf{N}^*,d\mid m, then if a≡b(modm)a\equiv b\pmod m, a≡b(modd)a\equiv b\pmod d.
  • If a,b∈Z,d,m∈N∗a,b\in\mathbf{Z},d,m\in\mathbf{N}^* and a≡b(modm)a\equiv b\pmod m, then (a,m)=(b,m)(a,m)=(b,m). If dd divides mm and one of a,ba,b, then dd must divide the other of a,ba,b as well.

Another property is the multiplicative inverse. See multiplicative inverse.

Congruence Classes and Residue Systems

For convenience, for sets A,BA,B and an element rr, introduce the following notation:

  • r+A:={r+a:a∈A}r+A:=\{r+a:a\in A\};
  • rA:={ra:a∈A}rA:=\{ra:a\in A\};
  • A+B:={a+b:a∈A,b∈B}A+B:=\{a+b:a\in A,b\in B\};
  • AB:={ab:a∈A,b∈B}AB:=\{ab:a\in A,b\in B\}.
Congruence Class

For a nonzero integer mm, partition all integers into ∣m∣|m| pairwise disjoint sets such that any two numbers in the same set are congruent modulo mm. We call each of these ∣m∣|m| sets a congruence class or residue class modulo mm. Write r mod mr\bmod m for the congruence class containing the integer rr modulo mm.

It is not difficult to prove that for every nonzero integer mm, the partition above exists and is unique.

It follows from the definition of congruence classes that:

  • r mod m={r+km:k∈Z}r\bmod m=\{r+km:k\in\mathbf{Z}\};
  • r mod m=s mod m  ⟺  r≡s(modm)r\bmod m=s\bmod m\iff r\equiv s\pmod m;
  • For any r,s∈Zr,s\in\mathbf{Z}, either r mod m=s mod mr\bmod m=s\bmod m or (r mod m)∩(s mod m)=∅(r\bmod m)\cap (s\bmod m)=\varnothing;
  • If m1∣mm_1\mid m, then for every integer rr, r+mZ⊆r+m1Zr+m\mathbf{Z}\subseteq r+m_1\mathbf{Z}.

Since congruence is an equivalence relation, a congruence class is an equivalence class of the congruence relation.

Let the set of all congruence classes modulo mm be denoted by Zm\mathbf{Z}_m, that is,

Zm:={r mod m:0≤r<m}\mathbf{Z}_m:=\{r\bmod m:0\leq r<m\}

It is easy to see that:

  • For every integer aa, a+Zm=Zma+\mathbf{Z}_m=\mathbf{Z}_m;
  • For every integer coprime to mm, denoted bb, bZm=Zmb\mathbf{Z}_m=\mathbf{Z}_m.

By the definition of a quotient group, Zm=Z/mZ\mathbf{Z}_m=\mathbf{Z}/m\mathbf{Z}, so we sometimes also write Z/mZ\mathbf{Z}/m\mathbf{Z} for Zm\mathbf{Z}_m.

The pigeonhole principle gives:

  • Among any m+1m+1 integers, two are congruent modulo mm.
  • There exist mm integers that are pairwise incongruent modulo mm.

This gives the definition of a complete residue system:

(Complete) Residue System

For mm integers a1,a2,…,ama_1,a_2,\dots,a_m, if for every number xx there is exactly one aia_i such that xx is congruent to aia_i modulo mm, then these mm integers a1,a2,…,ama_1,a_2,\dots,a_m are called a complete residue system, or simply a residue system, modulo mm.

We can also define the following systems modulo mm:

  • Least nonnegative (complete) residue system: 0,…,m−10,\dots,m-1;
  • Least positive (complete) residue system: 1,…,m1,\dots,m;
  • Absolute least (complete) residue system: −⌊m/2⌋,…,−⌊−m/2⌋−1-\lfloor m/2\rfloor,\dots,-\lfloor -m/2\rfloor-1;
  • Greatest nonpositive (complete) residue system: −m+1,…,0-m+1,\dots,0;
  • Greatest negative (complete) residue system: −m,…,−1-m,\dots,-1.

Unless stated otherwise, we generally use the least nonnegative residue system.

We note that the following proposition holds:

  • In any congruence class modulo mm, any two integers a1,a2a_1,a_2 satisfy (a1,m)=(a2,m)(a_1,m)=(a_2,m).

Consider the congruence class r mod mr\bmod m. If (r,m)=1(r,m)=1, then every element of this congruence class is coprime to mm. This suggests that we may be able to determine the structure of the set of all integers coprime to mm in a similar way.

Reduced Congruence Class

For a congruence class r mod mr\bmod m, if (r,m)=1(r,m)=1, then the class is called a reduced congruence class or reduced residue class.

Denote the number of reduced residue classes modulo mm by φ(m)\varphi(m); this is called the Euler totient function.

Let the set of all reduced congruence classes modulo mm be denoted by Zm∗\mathbf{Z}_m^*, that is,

Zm∗:={r mod m:0≤r<m,(r,m)=1}\mathbf{Z}_m^*:=\{r\bmod m:0\leq r<m,(r,m)=1\}
Warning

For every integer aa and every integer coprime to mm, denoted bb, bZm∗=Zm∗b\mathbf{Z}_m^*=\mathbf{Z}_m^*, but a+Zm∗a+\mathbf{Z}_m^* is not necessarily Zm∗\mathbf{Z}_m^*. This differs from Zm\mathbf{Z}_m.

The pigeonhole principle gives:

  • Among any φ(m)+1\varphi(m)+1 integers coprime to mm, two are congruent modulo mm.
  • There exist φ(m)\varphi(m) integers coprime to mm that are pairwise incongruent modulo mm.

This gives the definition of a reduced residue system:

Reduced Residue System

For t=φ(m)t=\varphi(m) integers a1,a2,…,ata_1,a_2,\dots,a_t, if (ai,m)=1, ∀1≤i≤t(a_i,m)=1,~\forall 1\leq i\leq t, and for every number satisfying (x,m)=1(x,m)=1, namely xx, there is exactly one aia_i such that xx is congruent to aia_i modulo mm, then these tt integers a1,a2,…,ata_1,a_2,\dots,a_t are called a reduced residue system, reduced system of residues, or simplified residue system modulo mm.

Similarly, we can define the least nonnegative reduced residue system and related concepts.

Unless stated otherwise, we generally use the least nonnegative reduced residue system.

Composition of Residue Systems

For a positive integer mm, we have the following theorem:

  • If m=m1m2, 1≤m1,m2m=m_1m_2,~1\leq m_1,m_2, and Zm1,Zm2Z_{m_1},Z_{m_2} are complete residue systems modulo m1,m2m_1,m_2 respectively, then for any integer coprime to m1m_1, denoted aa,

    Zm=aZm1+m1Zm2.Z_m=aZ_{m_1}+m_1Z_{m_2}.

    This is a complete residue system modulo mm. Furthermore, if m=∏i=1kmi, 1≤m1,m2,…,mkm=\prod_{i=1}^k m_i,~1\leq m_1,m_2,\dots,m_k, and Zm1,…,ZmkZ_{m_1},\dots,Z_{m_k} are complete residue systems modulo m1,…,mkm_1,\dots,m_k respectively, then:

    Zm=∑i=1k(∏j=1i−1mj)Zmi.Z_m=\sum_{i=1}^k\left(\prod_{j=1}^{i-1}m_j\right)Z_{m_i}.

    This is a complete residue system modulo mm.

Proof

It is enough to prove that for ax+m1y≡ax′+m1y′(modm1m2)ax+m_1y\equiv ax'+m_1y'\pmod{m_1m_2}, where x,x′∈Zm1x,x'\in Z_{m_1} and y,y′∈Zm2y,y'\in Z_{m_2}, we have:

ax+m1y=ax′+m1y′.ax+m_1y=ax'+m_1y'.

In fact, since m1∣m1m2m_1\mid m_1m_2, we have ax+m1y≡ax′+m1y′(modm1)ax+m_1y\equiv ax'+m_1y'\pmod{m_1}, and hence ax≡ax′(modm1)ax\equiv ax'\pmod{m_1}. Since (a,m1)=1(a,m_1)=1, we obtain x≡x′(modm1)x\equiv x'\pmod{m_1}, and therefore x=x′x=x'.

Furthermore, m1y≡m1y′(modm1m2)m_1y\equiv m_1y'\pmod{m_1m_2}, so y≡y′(modm2)y\equiv y'\pmod{m_2}, that is, y=y′y=y'.

Therefore,

ax+m1y=ax′+m1y′.ax+m_1y=ax'+m_1y'.
  • If m=m1m2, 1≤m1,m2,(m1,m2)=1m=m_1m_2,~1\leq m_1,m_2,(m_1,m_2)=1, and Zm1∗,Zm2∗Z_{m_1}^*,Z_{m_2}^* are reduced residue systems modulo m1,m2m_1,m_2 respectively, then:

    Zm∗=m2Zm1∗+m1Zm2∗.Z_m^*=m_2Z_{m_1}^*+m_1Z_{m_2}^*.

    This is a reduced residue system modulo mm.

Tip

This theorem is equivalent to proving that the Euler totient function is a multiplicative function.

Proof

Let Zm1,Zm2Z_{m_1},Z_{m_2} be complete residue systems modulo m1,m2m_1,m_2, respectively. We have already proved that

Zm=m2Zm1+m1Zm2Z_m=m_2Z_{m_1}+m_1Z_{m_2}

is a complete residue system modulo mm. Let M={a∈Zm:(a,m)=1}⊆ZmM=\{a\in Z_m:(a,m)=1\}\subseteq Z_m. Clearly, MM is a reduced residue system modulo mm, so it is enough to prove M=Zm∗M=Z_m^*.

Clearly, Zm∗⊆ZmZ_m^*\subseteq Z_m.

Take any m2x+m1y∈Mm_2x+m_1y\in M, where x∈Zm1x\in Z_{m_1} and y∈Zm2y\in Z_{m_2}. We have (m2x+m1y,m1m2)=1(m_2x+m_1y,m_1m_2)=1, and since (m1,m2)=1(m_1,m_2)=1,

1=(m2x+m1y,m1)=(m2x,m1)=(x,m1),1=(m_2x+m_1y,m_1)=(m_2x,m_1)=(x,m_1), 1=(m2x+m1y,m2)=(m1y,m2)=(y,m2).1=(m_2x+m_1y,m_2)=(m_1y,m_2)=(y,m_2).

Therefore, x∈Zm1∗x\in Z_{m_1}^* and y∈Zm2∗y\in Z_{m_2}^*, so M⊆Zm∗M\subseteq Z_m^*.

Take any m2x+m1y∈Zm∗m_2x+m_1y\in Z_m^*, where x∈Zm1∗x\in Z_{m_1}^* and y∈Zm2∗y\in Z_{m_2}^*. We have (x,m1)=1(x,m_1)=1 and (y,m2)=1(y,m_2)=1, and since (m1,m2)=1(m_1,m_2)=1,

(m2x+m1y,m1)=(m2x,m1)=(x,m1)=1,(m_2x+m_1y,m_1)=(m_2x,m_1)=(x,m_1)=1, (m2x+m1y,m2)=(m1y,m2)=(x,m2)=1,(m_2x+m_1y,m_2)=(m_1y,m_2)=(x,m_2)=1,

Therefore (m2x+m1y,m1m2)=1(m_2x+m_1y,m_1m_2)=1, so Zm∗⊆MZ_m^*\subseteq M.

In conclusion,

Zm∗=m2Zm1∗+m1Zm2∗.Z_m^*=m_2Z_{m_1}^*+m_1Z_{m_2}^*.

This is a reduced residue system modulo mm.

Number-Theoretic Functions

A number-theoretic function (also called an arithmetic function) is a function whose domain is the positive integers. A number-theoretic function can also be viewed as a sequence.

Multiplicative Functions

Definition

In number theory, if a function f(n)f(n) satisfies f(1)=1f(1)=1 and f(xy)=f(x)f(y)f(xy)=f(x)f(y) for any coprime x,y∈N∗x, y \in\mathbf{N}^*, then f(n)f(n) is a multiplicative function.

In number theory, if a function f(n)f(n) satisfies f(1)=1f(1)=1 and f(xy)=f(x)f(y)f(xy)=f(x)f(y) for all x,y∈N∗x, y \in\mathbf{N}^*, then f(n)f(n) is a completely multiplicative function.

Properties

If f(x)f(x) and g(x)g(x) are both multiplicative functions, then the following functions are also multiplicative:

h(x)=f(xp)h(x)=fp(x)h(x)=f(x)g(x)h(x)=∑d∣xf(d)g(xd)\begin{aligned} h(x)&=f(x^p)\\ h(x)&=f^p(x)\\ h(x)&=f(x)g(x)\\ h(x)&=\sum_{d\mid x}f(d)g\left(\dfrac{x}{d}\right) \end{aligned}

For a positive integer xx, let its unique prime factorization be x=∏pikix=\prod p_i^{k_i}, where pip_i are primes.

If F(x)F(x) is multiplicative, then F(x)=∏F(piki)F(x)=\prod F(p_i^{k_i}).

If F(x)F(x) is completely multiplicative, then F(x)=∏F(piki)=∏F(pi)kiF(x)=\prod F(p_i^{k_i})=\prod F(p_i)^{k_i}.

Examples

  • Unit function: ε(n)=[n=1]\varepsilon(n)=[n=1]. (Completely multiplicative)
  • Identity function: id⁡k(n)=nk\operatorname{id}_k(n)=n^k; id⁡1(n)\operatorname{id}_{1}(n) is usually abbreviated as id⁡(n)\operatorname{id}(n). (Completely multiplicative)
  • Constant function: 1(n)=11(n)=1. (Completely multiplicative)
  • Divisor function: σk(n)=∑d∣ndk\sigma_{k}(n)=\sum_{d\mid n}d^{k}. σ0(n)\sigma_{0}(n) is usually abbreviated as d(n)d(n) or τ(n)\tau(n), and σ1(n)\sigma_{1}(n) is usually abbreviated as σ(n)\sigma(n).
  • Euler totient function: φ(n)=∑i=1n[(i,n)=1]\varphi(n)=\sum_{i=1}^n[(i,n)=1].
  • Möbius function: μ(n)={1n=10∃d>1,d2∣n(−1)ω(n)otherwise\mu(n)=\begin{cases}1&n=1\\0&\exists d>1,d^{2}\mid n\\(-1)^{\omega(n)}&\text{otherwise}\end{cases}, where ω(n)\omega(n) denotes the number of distinct prime factors of nn.

Additive Functions

Definition

In number theory, if a function f(n)f(n) satisfies f(1)=0f(1)=0 and f(xy)=f(x)+f(y)f(xy)=f(x)+f(y) for any coprime x,y∈N∗x, y \in\mathbf{N}^*, then f(n)f(n) is an additive function.

In number theory, if a function f(n)f(n) satisfies f(1)=0f(1)=0 and f(xy)=f(x)+f(y)f(xy)=f(x)+f(y) for all x,y∈N∗x, y \in\mathbf{N}^*, then f(n)f(n) is a completely additive function.

Additive Function

The additive function in this section is the number-theoretic Additive function; it should be distinguished from the Additive map in algebra.

Properties

For a positive integer xx, let its unique prime factorization be x=∏pikix=\prod p_i^{k_i}, where pip_i are primes.

If F(x)F(x) is additive, then F(x)=∑F(piki)F(x)=\sum F(p_i^{k_i}).

If F(x)F(x) is completely additive, then F(x)=∑F(piki)=∑F(pi)⋅kiF(x)=\sum F(p_i^{k_i})=\sum F(p_i)\cdot k_i.

Examples

For convenience, let the set of all primes be P\mathbf P.

  • The multiplicity of pp in the prime factorization: νp(n)=max⁡{k∈N:pk∣n}\nu_p(n) = \max\{k\in\mathbf N: p^k\mid n\}, where p∈Pp\in\mathbf P. (Completely additive)
  • The total number of prime factors: Ω(n)=∑p∈Pνp(n)\Omega(n)=\sum_{p \in\mathbf P} \nu_p(n). (Completely additive)
  • The number of distinct prime factors: ω(n)=∑p∈P[p∣n]\omega(n)=\sum_{p \in\mathbf P} [p \mid n].
  • The sum of all prime factors: a0(n)=∑p∈Pνp(n)⋅pa_0(n)=\sum_{p \in\mathbf P} \nu_p(n)\cdot p. (Completely additive)
  • The sum of distinct prime factors: a1(n)=∑p∈P[p∣n]⋅pa_1(n)=\sum_{p \in\mathbf P} [p \mid n] \cdot p.

Floor and Ceiling Functions

For a real number xx, define the floor function and ceiling function, respectively, by

⌊x⌋=max⁡{k∈Z:k≤x}, ⌈x⌉=min⁡{k∈Z:k≥x}.\lfloor x\rfloor = \max\{k\in\mathbf Z:k\le x\},~\lceil x\rceil = \min\{k\in\mathbf Z:k\ge x\}.

Using the floor function, a real number can be decomposed into its integer part and fractional part: x=⌊x⌋+{x}x = \lfloor x\rfloor + \{x\}. Here, {x}\{x\} denotes the fractional part of xx.

The floor and ceiling functions have the following basic properties: (x∈R, n∈Zx\in\mathbf R,~n\in\mathbf Z)

  • x∈Z  ⟺  x=⌊x⌋=⌈x⌉x\in\mathbf Z \iff x = \lfloor x\rfloor = \lceil x\rceil.
  • ⌈x⌉−⌊x⌋=[x∉Z]\lceil x\rceil - \lfloor x\rfloor = [x\notin\mathbf Z].
  • x−1<⌊x⌋≤x≤⌈x⌉<x+1x - 1 < \lfloor x\rfloor \le x \le \lceil x\rceil < x + 1.
  • ⌊−x⌋=−⌈x⌉, ⌈−x⌉=−⌊x⌋\lfloor -x\rfloor = -\lceil x\rceil,~\lceil -x\rceil = -\lfloor x\rfloor.
  • ⌊x+n⌋=⌊x⌋+n, ⌈x+n⌉=⌈x⌉+n\lfloor x + n\rfloor = \lfloor x\rfloor + n,~\lceil x + n\rceil = \lceil x \rceil + n.
  • Both ⌊x⌋\lfloor x\rfloor and ⌈x⌉\lceil x\rceil are monotonically nondecreasing functions of xx.

When proving equalities involving floor or ceiling functions, the following equivalent forms are often useful: (x∈R, n∈Zx\in\mathbf R,~n\in\mathbf Z)

  • ⌊x⌋=n  ⟺  n≤x<n+1  ⟺  x−1<n≤x\lfloor x\rfloor = n \iff n \le x < n + 1 \iff x - 1 < n \le x.
  • ⌈x⌉=n  ⟺  n−1<x≤n  ⟺  x≤n<x+1\lceil x\rceil = n \iff n - 1 < x \le n \iff x \le n < x + 1.

When proving inequalities involving floor or ceiling functions, the following equivalent forms are often useful: (x∈R, n∈Zx\in\mathbf R,~n\in\mathbf Z)

  • x<n  ⟺  ⌊x⌋<nx < n \iff \lfloor x\rfloor < n.
  • n<x  ⟺  n<⌈x⌉n < x \iff n < \lceil x\rceil.
  • x≤n  ⟺  ⌈x⌉≤nx \le n \iff \lceil x\rceil \le n.
  • n≤x  ⟺  n≤⌊x⌋n \le x \iff n \le \lfloor x\rfloor.

The properties involving sums and differences are as follows: (x,y∈Rx,y\in\mathbf R)

  • ⌊x⌋+⌊y⌋≤⌊x+y⌋≤⌊x⌋+⌊y⌋+1\lfloor x\rfloor + \lfloor y\rfloor \le \lfloor x + y\rfloor \le \lfloor x\rfloor + \lfloor y\rfloor + 1, with exactly one equality holding.
  • ⌈x⌉+⌈y⌉−1≤⌈x+y⌉≤⌈x⌉+⌈y⌉\lceil x\rceil +\lceil y\rceil -1\leq \lceil x+y\rceil \leq \lceil x\rceil +\lceil y\rceil, with exactly one equality holding.
  • ⌊∣x−y∣⌋≤∣⌊x⌋−⌊y⌋∣≤⌈∣x−y∣⌉\lfloor|x - y|\rfloor \le |\lfloor x\rfloor - \lfloor y\rfloor| \le \lceil|x - y|\rceil.
  • ⌊∣x−y∣⌋≤∣⌈x⌉−⌈y⌉∣≤⌈∣x−y∣⌉\lfloor|x - y|\rfloor \le |\lceil x\rceil - \lceil y\rceil| \le \lceil|x-y|\rceil.

The properties involving quotients are as follows: (x∈R, n∈Z, m∈Z+x\in\mathbf R,~n\in\mathbf Z,~m\in\mathbf Z_+)

  • ⌈nm⌉=⌊n+m−1m⌋, ⌊nm⌋=⌈n−m+1m⌉\left\lceil\dfrac{n}{m}\right\rceil = \left\lfloor\dfrac{n+m-1}{m}\right\rfloor,~\left\lfloor\dfrac{n}{m}\right\rfloor = \left\lceil\dfrac{n-m+1}{m}\right\rceil.
  • ⌊x+nm⌋=⌊⌊x⌋+nm⌋, ⌈x+nm⌉=⌈⌈x⌉+nm⌉\left\lfloor\dfrac{x + n}{m} \right\rfloor = \left\lfloor\dfrac{\lfloor x\rfloor + n}{m} \right\rfloor,~\left\lceil\dfrac{x + n}{m} \right\rceil = \left\lceil\dfrac{\lceil x\rceil + n}{m} \right\rceil.
  • ⌊⌊x/n⌋m⌋=⌊xnm⌋, ⌈⌈x/n⌉m⌉=⌈xnm⌉\left\lfloor\dfrac{\lfloor x/n\rfloor}{m}\right\rfloor = \left\lfloor\dfrac{x}{nm}\right\rfloor,~\left\lceil\dfrac{\lceil x/n\rceil}{m}\right\rceil = \left\lceil\dfrac{x}{nm}\right\rceil.
  • For x>0x > 0, ⌊xm⌋=∑k=1⌊x⌋[m∣k]\displaystyle\left\lfloor\dfrac{x}{m}\right\rfloor = \sum_{k=1}^{\lfloor x\rfloor}[m\mid k].

The second and third properties can both be viewed as direct consequences of the following result:

  • Let ff be a continuous, strictly increasing function, and suppose that whenever f(x)∈Zf(x)\in\mathbf Z, we have x∈Zx\in\mathbf Z. Then

    ⌊f(x)⌋=⌊f(⌊x⌋)⌋, ⌈f(x)⌉=⌈f(⌈x⌉)⌉.\lfloor f(x)\rfloor = \lfloor f(\lfloor x\rfloor)\rfloor,~ \lceil f(x)\rceil = \lceil f(\lceil x\rceil)\rceil.

    ??? note "Proof" By symmetry, it is enough to prove the first equality. If xx is an integer, the claim is obvious. Otherwise, ⌊x⌋<x\lfloor x\rfloor < x. By the monotonicity of ff and the floor function, ⌊f(x)⌋≥⌊f(⌊x⌋)⌋\lfloor f(x)\rfloor \ge \lfloor f(\lfloor x\rfloor)\rfloor. If equality does not hold, let y=⌊f(x)⌋y = \lfloor f(x)\rfloor. It satisfies ⌊f(⌊x⌋)⌋<y≤⌊f(x)⌋\lfloor f(\lfloor x\rfloor)\rfloor < y \le \lfloor f(x)\rfloor, which is equivalent to f(⌊x⌋)<y≤f(x)f(\lfloor x\rfloor) < y \le f(x). By the continuity of ff, there exists ⌊x⌋<x0≤x\lfloor x\rfloor < x_0 \le x such that f(x0)=yf(x_0)=y. Since y∈Zy\in\mathbf Z, we have x0∈Zx_0\in\mathbf Z, contradicting the definition of ⌊x⌋\lfloor x\rfloor. Therefore equality holds, namely ⌊f(x)⌋=⌊f(⌊x⌋)⌋\lfloor f(x)\rfloor = \lfloor f(\lfloor x\rfloor)\rfloor.

Finally, here are some results about sums involving floor and ceiling functions: (x∈R, n∈Z, m∈Z+x\in\mathbf R,~n\in\mathbf Z,~m\in\mathbf Z_+)

  • n=⌊n2⌋+⌈n2⌉n = \left\lfloor\dfrac{n}{2}\right\rfloor + \left\lceil\dfrac{n}{2}\right\rceil.
  • n=⌊nm⌋+⌊n+1m⌋+⋯+⌊n+m−1m⌋n = \left\lfloor\dfrac{n}{m} \right\rfloor + \left\lfloor\dfrac{n+1}{m} \right\rfloor + \cdots + \left\lfloor\dfrac{n+m-1}{m} \right\rfloor.
  • n=⌈nm⌉+⌈n−1m⌉+⋯+⌈n−m+1m⌉n = \left\lceil\dfrac{n}{m} \right\rceil + \left\lceil\dfrac{n-1}{m} \right\rceil + \cdots + \left\lceil\dfrac{n-m+1}{m} \right\rceil.
  • ⌊mx⌋=⌊x⌋+⌊x+1m⌋+⋯+⌊x+m−1m⌋\lfloor mx\rfloor = \lfloor x\rfloor + \left\lfloor x+\dfrac{1}{m}\right\rfloor + \cdots + \left\lfloor x+\dfrac{m-1}{m}\right\rfloor.
  • ⌈mx⌉=⌈x⌉+⌈x−1m⌉+⋯+⌈x−m−1m⌉\lceil mx\rceil = \lceil x\rceil + \left\lceil x - \dfrac{1}{m}\right\rceil + \cdots + \left\lceil x - \dfrac{m-1}{m}\right\rceil.
  • If m⊥nm\perp n, then ∑k=1m−1⌊knm⌋=12(n−1)(m−1)\displaystyle\sum_{k=1}^{m-1}\left\lfloor\dfrac{kn}{m}\right\rfloor=\dfrac{1}{2}(n-1)(m-1).
  • If m⊥nm\perp n, then ∑k=1m−1⌈knm⌉=12(n+1)(m−1)\displaystyle\sum_{k=1}^{m-1}\left\lceil\dfrac{kn}{m}\right\rceil=\dfrac{1}{2}(n+1)(m-1).

Derivations of these and more general sums of similar forms can be found on the Euclidean algorithm page.

More properties and applications of floor and ceiling functions can be found on the following pages:

References and Notes

  • Pan Chengdong, Pan Chengbiao. Elementary Number Theory. Peking University Press.
  • Floor and ceiling functions - Wikipedia
  • Graham, Ronald L., Donald E. Knuth, and Oren Patashnik. "Concrete mathematics: a foundation for computer science." (1989).

Footnotes

  1. std::gcd - cppreference.com ↩

This content comes from OI Wiki: Basic Number Theory. See the original for authors and revision history. AIOJ has adapted the formatting, in-site links, and resource paths.

Content is shared under CC BY-SA 4.0 and SATA license; additional terms are governed by the original notice. Thanks to the OI Wiki authors and contributors; per the SATA terms, please visit the OI Wiki repository and star it to show your support.