Beruflich Dokumente
Kultur Dokumente
James Emery
Last Addition or Edit: 6/7/2014
Contents
1 Introduction
2 Prime Numbers
10
14
17
19
23
11 Decimal Expansions
26
12 Fermats Theorem
27
28
1
29
31
33
17 Carmichael Numbers
35
36
19 Mersenne Primes
37
40
21 Wilsons Theorem
41
42
23 Quadratic Residues
42
24 Diophantine Equations
42
25 Goldbachs Conjecture
42
43
43
43
29 Perfect Numbers
47
30 Twin Primes
47
48
32 Repeating Decimals
49
50
34 Fibonacci Numbers
52
53
36 Bibliography
53
Introduction
Prime Numbers
number is not divisible by any of the finite primes. But a number is either
divisible by a prime, or a prime itself. This is a contradiction. Therefore
there are an infinite number of primes. This argument was given by Euclid.
The prime number theorem says that the number of primes less than natural
number n is approximately equal to
n
.
ln(n)
The Prime Number Theorem. If (n) is the number of primes less than
n, then the ratio of (n) to n/ ln(n) goes to 1 as n goes to ,
lim
ln(n)
(n)
n
= 1.
(n)
n/ ln(n)
ratio
4
4.3
0.93
25
21.7
1.15
168
144.8
1.16
1,229
1,086
1.13
9,592
8,686
1.10
78,498
72,382
1.08
664,579
620,420
1.07
5,761,455
5,428,681
1.06
50,847,534 48,254,942 1.05
455,052,511 434,394,482 1.048
Given two positive integers b1 and b2 , we shall show how to compute the
gcd. Let us assume that b1 > b2 . We can divide a larger integer by a smaller
one getting a quotient and a remainder. So suppose b1 = 108 and b2 = 30.
Dividing 108 by 30 we get a quotient of 3 with a remainder of 18. The
remainder 18 is less than the divisor 30. We can write this as
108 = 3 30 + 18,
and . The remainder becomes the next divisor in a continuing sequence:
30 = 1 18 + 12.
18 = 1 12 + 6
12 = 2 6 + 0.
When we get a zero remainder, the previous remainder is the gcd. So gcd
= 6. Next we shall prove this algorithm always produces the gcd.
So we start with
b1 = k1 b2 + b3 ,
where k1 and b3 are integers. Number k1 is the quotient, b2 is the divisor,
and b3 is the remainder. A divisor is always greater than a remainder, so
b2 > b3 . We may continue this division
b1 = k1 b2 + b3 ,
b2 = k2 b3 + b4
b3 = k3 b4 + b5
....................
bn1 = kn1 bn + bn+1
bn = kn bn+1 + bn+2 ,
until the remainder bn+2 is zero, when the division stops. We have a strictly
decreasing sequence of integers
b1 > b2 > b3 > .... > bn+2 .
5
Eventually we must reach a step n where the remainder bn+2 is zero, where
we cant continue the division. At this point we claim that g = bn+1 is the
greatest common divisor of the integers b1 and b2 .
Going backwards, we have
bn = kn bn+1 ,
bn1 = kn1 bn + bn+1 ,
bn2 = kn2 bn1 + bn ,
....................
b1 = k1 b2 + b3 ,
showing that bn+1 eventually divides b2 and b1 .
Explicitly from the first equation
bn = kn bn+1 ,
we see that bn+1 divides bn . Continuing down the list of equations, we see
that for each k, bk+1 divides bk , and thus ultimately bn+1 divides b2 and b1 .
So g = bn+1 is a common divisor of b2 and b1 . Next we must prove that it is
the largest common divisor.
So suppose h is any other common divisor. That is suppose that h divides
b1 and b2 . Then from the first equation of the first list above, namely
b1 = k1 b2 + b3 ,
h must divide b3 , and so from the second equation it must divide b4 , and so
on, down the list, and so h must ultimately divide bn+1 . Hence
bn+1 h.
Therefore g = bn+1 is the gcd of m and n.
Note. Our assumption that m = b1 > b2 = n in the calculation is not
important, because if m=b1 < b2 = n the first step will be
b1 = k1 b2 + b3 = 0 b2 + b3 ,
that is b3 = b1 , so the second step in effect is restarting the calculation,
reversing the positions of b1 and b2 .
6
Substituting for bn in
g = n1 bn1 + n1 bn ,
we have
g = n1 bn1 + n1 (bn2 kn2 bn1 )
= n1 bn2 + (n1 n1 kn2 )bn1
= n2 bn2 + n2 bn1 ,
where
n2 = n1
and
n2 = n1 n1 kn2
This relationship will be repeated, so that at the pth step we find
g = p bp + p bp+1 ,
where
p = p+1
and
p = p+1 p+1 kp .
So finally
g = 1 b1 + 1 b2 .
Thus by saving the quotients k1 , k2 , ...kn1 we can construct the numbers 1
and 1 .
Corollary. If integers m and n are relatively prime, then m mod(n) has a
multiplicative inverse mod(n).
Proof. We have integers and so that
1 = m + n,
So that is the multiplicative inverse of m in the ring Zn , that is
m = 1 mod(n),
8
(m, n) = m + n.
Proposition. If r is the remainder on division of a by b, then
(a, b) = (b, r).
Proof. Suppose
a = kb + r.
From this (b, r) divides a. Because it also divides b, it thus divides (a, b). We
have
r = a kb,
and so because (a, b) divides both a and b, it divides r. Therefore (a, b)
divides both b and r, so (a, b) divides (b, r). Obviously two positive integers
that divide each other are equal. It follows that (a, b) = (b, r)
This program computes the gcd(m,n) of two integers m and n, and computes
numbers and such that
gcd(m, n) = m + n
Running the program:
Example 1.
c:\je\py>python gcd.py 510510 27170
m= 510510
n= 27170
510510 = 18 * 27170 + 21450
27170 = 1 * 21450 + 5720
21450 = 3 * 5720 + 4290
5720 = 1 * 4290 + 1430
4290 = 3 * 1430 + 0
10
11
b2=r
v[0]=g
#print
#print " number of divisions n=",n
#print " b="
#for i in range(1,len(b)):
# print " b[",i,"]=",b[i]
#print " length of k=",len(k)
#print " quotients=",k
#for i in range(1,len(k)):
# print " k[",i,"]=",k[i]
#print " remainders=",rm
#for i in range(1,len(rm)):
# print " rm[",i,"]=",rm[i]
alpha=1
beta=-k[n-1]
#print " g=alpha*b[n-1]+beta*b[n]=",alpha*b[n-1]+beta*b[n]
p=n-2
while (p>0):
tmp=alpha
alpha=beta
beta=tmp-beta*k[p]
#print "p=",p
#print " g=alpha*b[p]+beta*b[p+1]=",alpha*b[p]+beta*b[p+1]
p=p-1
#print
#print " alpha=",alpha," beta=",beta
#print " g=alpha*b[1]+beta*b[2]=",alpha*b[1]+beta*b[2]
v[1]=alpha
v[2]=beta
return v
#function least common multiple
def lcm(m,n):
v=m*n/gcd(m,n)
return v
13
#main
#print sys.argv
#print sys.argv[0]
na=len(sys.argv)
#print number of arguments = , na
if( na < 3):
print "gcd.py, greatest common divisor of two integers"
print "Usage: python gcd.py m n "
sys.exit(0)
m=int(sys.argv[1])
print " m= ",m
n=int(sys.argv[2])
print " n= ",n
v=gcd(m,n)
#print " length v = ",len(v)
print " v = [gcd,alpha,beta]=",v
print " gcd(m,n)= ",v[0]
alpha=v[1]
#print " alpha=",alpha
beta=v[2]
#print " beta=",beta
print " alpha*m+beta*n= ",alpha*m+beta*n
Here is a java program for the calculation of the gcd, the numbers and
If the gcd =1, it calculates the multiplicative inverse of m mod n.
//gcdex.java, greatest common divisor of two integers 1-1-2008
class gcdex{
public static void main(String args[]) {
int b[];
int a[];
int na;
14
int m;
int n;
int g;
a = new int[2];
b = new int[10];
na=args.length;
if(args.length < 1){
System.out.println(" greatest common divisor of two integers " );
System.out.println(" Usage: java gcd m n " );
return;
}
for(int i=0;i<na;i++){
b[i]=Integer.parseInt(args[i]);
}
m=b[0];
n=b[1];
g=gcd(m,n,a);
System.out.print(" gcd= " + g + "\n");
System.out.print(" a1= " + a[0] + " a2= " + a[1] + "\n");
g=a[0]*m+a[1]*n;
System.out.print(" a1*m+*a2*n= " + g + "\n");
}
//c+ gcd function greatest common devisor of 2 positive integers
public static int gcd(int m,int n, int[] a){
/**
*
Input:
*
m,n two integers
*
Output:
*
a
two element double array such that
*
gcd = a[0]*m + a[1]*n
*
Returned Value:
*
the greatest common divisor of m and n
* Example program gcdex.java
*/
int k[];
int
int
int
int
int
int
int
b1;
b2;
b3;
na;
nk;
ns;
r;
int alpha;
int beta;
int g;
int j;
int tmp;
nk=100;
15
k = new int[nk];
b1=m;
b2=n;
tmp=b1/b2;
r=b1-tmp*b2;
if(r == 0){
System.out.print(" gcd= "
alpha=0;
beta=1;
g=alpha*b1+beta*b2;
+ b2 + "\n");
return g;
}
System.out.print(" b1= " + b1 + " b2= " + b2 + "\n");
ns=0;
while(r>0){
k[ns]=b1/b2;
r=b1-k[ns]*b2;
System.out.print(" k[" + ns + "] = " + k[ns] + " r= " + r + "\n");
if(r > 0){
b1=b2;
b2=r;
System.out.print(" b1= " + b1 + " b2= " + b2 + "\n");
ns=ns+1;
}
}
g=b2;
j=ns-1;
alpha=1;
beta=-k[j];
j=j-1;
while(j >= 0){
tmp=alpha;
alpha=beta;
beta=tmp - k[j]*beta;
j=j-1;
}
a[0]=alpha;
a[1]=beta;
return g;
}
}
16
Application. To compute the greatest common divisor (a, b),of two integers a and b, we can compute the remainder r of a/b and compute (b, r),
recursively. Stopping when the value of b reaches zero.
Here is a Scheme function to do this calculation:
(define (gcd1 a b)
(if (= b 0) a (gcd1 b (remainder a b))))
We have used gcd1 as the name of the function, because there is an actual
gcd function built into Scheme.
This program computes gcdexample(m,n) where the two integers are defined in the program. See also program gcd.py where the integers are defined
as command line parameters. The python program computes with long integers.
#gcdexample.py greatest common divisor, m and n defined in program main
#also see command line version gcd.py, getting m and n from command line parameters
import sys
#
#function greatest common divisor
def gcd(m,n):
b1=m
b2=n
while (b2 > 0):
v=b2
q=b1/b2
#note, if b2>b1 then q=0, then r=b1 so b1 and b2 are switched
r=b1-b2*q;
b1=b2
b2=r
return v
#function least common multiple
def lcm(m,n):
v=m*n/gcd(m,n)
return v
17
#program main
m=2*3*5*7*11*13*14*15*200*189*3574
n=91*93*101*3*7*35789*1000*13*14
print " m=",m
print " n=",n
k=gcd(m,n)
print " gcd(m,n)= ",k
j=lcm(m,n)
print " lcm(m,n)= ",j
mdgcd=m/k
ndgcd=n/k
print " m=m/gcd =",mdgcd
print " n=n/gcd =",ndgcd
d=gcd(mdgcd,ndgcd)
print " gcd(m,n) = ",d
8.1
18
Modular Arithmetic
0
0
1
2
3
4
1
1
2
3
4
0
2
2
3
4
0
1
3
3
4
0
1
2
4
4
0
1
2
3
0
1
2
3
4
0
0
0
0
0
0
1
0
1
2
3
4
2
0
2
4
1
3
3
0
3
1
4
2
4
0
4
3
2
1
20
0
0
1
2
3
4
5
6
7
8
9
1
1
2
3
4
5
6
7
8
9
0
2
2
3
4
5
6
7
8
9
0
1
3
3
4
5
6
7
8
9
0
1
2
4
4
5
6
7
8
9
0
1
2
3
5
5
6
7
8
9
0
1
2
3
4
6
6
7
8
9
0
1
2
3
4
5
7
7
8
9
0
1
2
3
4
5
6
8
8
9
0
1
2
3
4
5
6
7
9
9
0
1
2
3
4
5
6
7
8
Notice that the following multiplication table for the integers mod 10, shows
that the numbers 2, 4, 5, 6, 8, which are not relatively prime to 10, do not
have multiplicative inverses. For example, in the row for multiplication by 2,
21
0
1
2
3
4
5
6
7
8
9
0
0
0
0
0
0
0
0
0
0
0
1
0
1
2
3
4
5
6
7
8
9
2
0
2
4
6
8
0
2
4
6
8
3
0
3
6
9
2
5
8
1
4
7
4
0
4
8
2
6
0
4
8
2
6
5
0
5
0
5
0
5
0
5
0
5
6
0
6
2
8
4
0
6
2
8
4
7
0
7
4
1
8
5
2
9
6
3
8
0
8
6
4
2
0
8
6
4
2
9
0
9
8
7
6
5
4
3
2
1
the reduced residue system mod 10, and are written Z10
, and form a multiplicative group, that is they have inverses and are closed.
If m and n are equal mod(k), then m n is divisible by k. If j is any
integer, then jm and jn are equal mod(k), because the difference jm jn =
j(m n) is a multiple of k. But the opposite is not true, if jm and jn are
equal mod(k), then m and n are not necessarily equal mod(k). This can
be seen from the multiplication table above. For example, 6 7 = 2 and
6 2 = 2, yet 7 does not equal 2. If k is a prime, then Ik is a field, and the
cancellation law does hold.
The cancellation law does not hold in general for Ik , the ring of integers mod
22
10
The word totient comes from a Latin word meaning so many, and is pronounced to rhyme with quotient. The Euler Totient function, also called the
(n) function is a function on the set of positive integers, so that (n) is the
number of positive integers less than n, that are relatively prime to n. Recall
that two integers are relatively prime if their gcd, (m, n) = 1. If p is a prime,
then (1, p) = 1, so 1 is counted by the function.
If p is prime then no numbers less than p have a prime factor that is a
prime factor of p. Therefore we have the following theorem.
Theorem. If p is prime, then
(p) = p 1.
Theorem. If p is a prime then
(pk ) = pk1 (p 1).
Proof. This follows because if we list all of the integers from 1 to p we have
1, 2, 3, ..., p, p + 1, p + 2, ..., 2p, ..., pk
So one has repeatedly p 1 integers that are equivalent to 1, 2, 3, 4, ..., (p 1)
mod(p), followed by a multiple of p. This repeating occurs pk /p = pk1 times.
23
So all of these integers are relatively prime to pk except for the multiples of
p. It follows that there are pk1(p 1) of these numbers. So
(pk ) = pk1 (p 1).
So for example consider p = 32 . The list of numbers are
1, 2, 3, 4, 5, 6, 7, 8, 9.
So the relatively prime numbers to 32 = 9, skipping the multiples of 3, are
1, 2, 4, 5, 7, 8
So
(32 ) = 31 (3 1) = 6.
We write j|m to mean integer j divides integer m.
Theorem. If j|m, j|k and k = `mod(m), then j|`.
Proof. If j|m and j|k, then for some q1 , q2
m = q1 j
and
k = q2 j.
If k = `mod(m), then for some q3
` = k + q3 m = q2 j + q3 q1 j.
Corollary. If k is relatively prime to m and ` = kmod(m), then ` is relatively
prime to m.
Theorem. If m and n are relatively prime, then
(mn) = (m)(n).
Proof. Display the numbers 1, 2, 3, 4, ....., mn as an m by n matrix A, the
first row being
1, 2, 3, 4.....n
the second
n + 1, n + 2, n + 3, n + 4.....2n
24
and so on. In the first row, (n) of these numbers are relatively prime to n.
Consider the element A(1, k) in the first row that is relatively prime to n.
Every element of the kth column is equal mod(n) to A(1, k) by the nature of
matrix A. By the preceding corollary, every element of the kth column of A
is relatively prime to n.
In a given column k, the elements A(1, k), A(2, k), ..., A(m, k) are distinct mod(mn), because m and n are relatively prime allowing application of
the cancellation law. So they are equivalent to 1, 2, 3, 4, 5, 6, ..., m mod(m).
Therefore there are exactly (m) in each column that are relatively prime to
m. So there are (m)(n) relatively prime to both m and n.
Note. Obviously this result does not hold if m and n are not relatively
prime. For example let m = 4 and n = 6 then (m) = 2 and (n) = 1, but
(24) = 8.
Corollary If
n=
k
Y
pj j ,
k
Y
(pj j ).
j=1
j=1
k
Y
n 1
pj j
(pj 1).
j=1
=n
Qk
j=1 (pj
Qk
j=1 pj
(n) = n
1)
1
(1 ).
p
p|n
25
11
Decimal Expansions
26
= 10r 1,
12
Fermats Theorem
Fermats theorem says that if two integers a and m are relatively prime, a
raised to the power of (m) is equal to 1 mod(m).
27
13
14
(define (fast-exp b n)
(cond ((= n 0 ) 1 )
((even? n) (square (fast-exp b (/ n 2))))
(else (* b (fast-exp b (- n 1))))))
The line with the cond word in it is a kind if command, which here
returns 1 if the exponent is zero, or else goes to the next two lines handling
division by 2 and the recursive call.
Note that the conversion of the calculation, to a stack expression, and
then its evaluation right to left, is handled by the scheme interpreter itself.
15
This Scheme program comes from the book, Abelson, Harold and Sussman,
Gerald J., Structure and Interpretation of Computer Programs.
See Fermats Theorem on p89 of Elementary Theory of Numbers, by
Harriet Griffin, McGraw-Hill, 1954.
If a and m are relatively prime then a(m) = 1mod(m), where is the
Euler functions, the number of integers less than m and relatively prime
to m. If p is prime then (p) = p 1, so ap1 = 1mod(p) or ap = amod(p).
This is Fermats little theorem.
See file fermat-test.cs in the scheme directory.
Here are the Scheme functions for the Fermat test of a prime using Fermats little theorem, Abbelson and Sussman p42. So
(fermat-test n) returns #t if n is a prime, #f if n is not a prime
The Function fermat-test uses subfunctions:
square (square x), squares x
fast-exp, (fast-exp b n), raises b to the nth power
expmod, (expmod b e m), raises b to power e mod m
Definitions:
(define (square x) ( * x x))
31
(define (fast-exp b n)
(cond ((= n 0 ) 1 )
((even? n) (square (fast-exp b (/ n 2))))
(else (* b (fast-exp b (- n 1))))))
(define (expmod b e m)
(cond ((= e 0) 1 )
((even? e)
(remainder (square (expmod b (/ e 2) m)) m))
(else
(remainder (* b (expmod b (- e 1) m ))
m))))
(define (fermat-test n)
(define a (+ 2 (random (- n 2))))
(= (expmod a n n) a))
Picking 47 randomly as a positive integer less than 97, the following
function must return 47 if 97 is a prime according to Fermats little theorem.
(remainder (fast-exp 47 97) 97)
Now if we are using k to test n for being a prime in Fermats little theorem,
if k is not returned then n can not be a prime. However, if the function does
return k, it is very very likely that n is a prime, but not certain. So for
example
77105 = 77 mod(105),
even though 105 is not a prime. But trying more random k values adds
evidence that n is prime. So
32105 = 92 mod(105),
so 105 is not a prime. It would be worth while to test how often this false
detection of a prime might occur, to get some estimate of the probability of
such occurrence.
For example
32
(fermat-test 9973)
returns #t,
(fermat-test 10000)
returns #f
Now this function fermat-test uses a random number generator supplied
by scheme. This function is (random k) which supplies a integer in the
interval [0, k] (maybe not including 0 or k, check this). However, some kind
of pseudo random generator is being used by scheme, which can generate
only a finite number of possibilities. So if k is larger than the number of
possibilities, there is a problem. In that case use Fermats little theorem
directly, and supply your own random number a to check for n being prime
(expmod a n n)
and check that the result is a. Now if the supplied a is greater than
n, then if n is a prime, then the result b will not agree with a because the
returned number will be in the interval [0, n 1] while a is not. But of course
b = a mod(n).
See Fermats Theorem on p89 of Elementary Theory of Numbers, by
Harriet Griffin, McGraw-Hill, 1954.
If a and m are relatively prime then a(m) = 1mod(m), where is the
Euler function, the number of integers less than m and relatively prime to
m. If p is prime then (p) = p 1, so ap1 = 1mod(p) or ap = amod(p).
This is Fermats little theorem.
16
# primetest.py 3/30/13
import random
#+ function factorial
def factorial(n):
if(n == 0):
return 1
33
return n*factorial(n-1)
#+ function remainder of m divided by n, so m mod(n)
def remainder(m,n):
q=m/n
return m - q*n
#+ function square
def square(n):
return n*n
#+ function fexp fast exponential function, that is, fast pow(m,n)
def fexp(m,n):
#print " entering fexp, n= ",n
if(n == 0):
return 1
if(remainder(n,2) == 0):
# n is even
#print " n is even "
return square(fexp(m,n/2))
else:
# n is odd
#print " n is odd "
return m*square(fexp(m,n/2))
v=False
break
return v
#program main
print " d=a^n mod(n)\n"
n1=1097
n2=1154
print " primes between ", n1," and ",n2
for n in range(n1,n2):
v=isprime(n,10)
if v:
print n, " is prime"
print "primes\n"
print "101 103 107 109 113 127 131 137 139 149\n"
print "151 157 163 167 173 179 181 191 193 197 199\n"
print "881 883 887 907 911 919 929 937\n"
print "941 947 953 967 971 977 983 991\n"
print "997 1009 1013 1019 1021 1031 1033 1039\n"
print "1049 1051 1061 1063 1069 1087 1091 1093\n"
print "1097 1103 1109 1117 1123 1129 1151 1153\n"
print "1163 1171 1181 1187 1193 1201 1213 1217\n"
17
Carmichael Numbers
Using the Python program of the previous section, I found a problem with
the number 1105. The test always found this number to be a prime no matter
how many values of a that I used. So finally I tested for all of the numbers
with program
carmichael1105.py
It turns out that 1105 is a special number, called a Carmichael number
or pseudoprime. This is a number such that the Fermat prime test fails for
every number a. 1105 is the second Charmichael number. That 561 is a
Carmichael number can be seen with Korselts criterion. Indeed, n = 561 is
35
18
1105 = 5 13 17
(4 | 1104;
12 | 1104;
16 | 1104)
1729 = 7 13 19
(6 | 1728;
12 | 1728;
18 | 1728)
2465 = 5 17 29
(4 | 2464;
16 | 2464;
28 | 2464)
2821 = 7 13 31
(6 | 2820;
12 | 2820;
30 | 2820)
6601 = 7 23 41
(6 | 6600;
22 | 6600;
40 | 6600)
8911 = 7 19 67
(6 | 8910;
18 | 8910;
66 | 8910).
8911 = 7 19 67
(6 | 8910;
18 | 8910;
66 | 8910).
19
Mersenne Primes
37
is a product of two integers, each greater than 1, which proves the proposition.
As of August 2008, only 44 Mersenne primes were known; the largest
known prime number (232,582,657 1) is a Mersenne prime and in modern
times the largest known prime has nearly always been a Mersenne prime.
Like several previous Mersenne primes, it was discovered by a distributed
computing project on the Internet, known as the Great Internet Mersenne
Prime Search (GIMPS). GIMPS reported the finding of a potential 45th
Mersenne prime on 2008-08-23, and a potential 46th on 2008-09-06. GIMPS
now reports that two independent verifications of each potential M(p) prime
confirm them as prime. An announcement about both primes will be made
around 2008-09-17. Given the delay, chances are at least one of these has
over 10 million decimal digits.
From the identity
(xn y n ) = (x y)(xn1 + xn2 y + +xn3 y 2 + ... + y n1),
we can write
2mn 1 = (2m 1)(2m(n1) + 2m(n2) + 2m(n3) + 1).
It follows that if a Mersenne number is a prime, then it must be of the form
2p 1,
where p is a prime.
There are 48 known Mersenne primes as of February 2013.
n
1
2
3
4
5
6
7
8
9
17
48
p
2
3
5
7
13
17
19
31
61
2281
57,885,161
Mp
3
7
31
127
8191
131071
524287
2147483647
2305843009213693951
446087557...132836351
581887266...724285951
digits
1
1
2
3
4
6
6
10
19
687
17,425,170
Date
430BCE
430BCE
300BCE
300BCE
1456
1588
1588
1772
1883
Oct 1952
Jan 25,2013
Discoverer
Greeks
Greeks
Greeks
Greeks
Anonomous
Pietro Cataldi
Pietro Cataldi
Euler
I. M. Pervushin
Raphael Robinson
Curtis Cooper
This last prime number is also the largest known prime number.
39
Method
...
...
...
...
Trail Division
Trial Division
Trial Division
Trial Division
Lucus Sequences
LLT SWAC
GIMPS PC
20
Proof. Let K = k1 ...kn be the product of the ki0 s. For each ki define
Ki = K/ki. Then Ki and ki are relatively prime, thus Ki has an inverse Ki0
in Iki . Write
x = a1 K1 K10 + a2 K2 K20 + ... + an Kn Kn0 .
In Ik1
x = a1 + 0... + 0 = a1 ,
because K1 K10 = 1 and k1 is a factor of the other terms. Thus
x = a1 mod(k1 ).
The other equations are satisfied by x similarly. To calculate Ki0 , calculate
the gcd of Ki and k1 , namely, (Ki , ki) = 1, and in the process numbers so
that
1 = Ki + ki.
Then select a number Ki0 from the set {1, 2, 3, ..., ki 1} that is congruent to
.
See Apostol for applications of the Chinese Remainder Theorem.
21
Wilsons Theorem
22
23
Quadratic Residues
If
x2 = a mod(m),
has a solution, then a is called a quadratic residue of m.
24
Diophantine Equations
Diophantine (die oh fan tine) Equations are equations that are to be solved
by integers.
25
Goldbachs Conjecture
42
26
1
,
s
n=1 n
for the real part of s greater than 1. The definition is extended to the
whole complex plane by analytic continuation. The Riemann zeta function
is analytic everywhere except at s = 1 where it has a simple pole with residue
1. The Riemann zeta function has a role in the analytic proof of the prime
number theorem. See Apostol.
27
28
Given a list of the first n positive integers, we can find all of the primes
in the list by first crossing off all multiples of 2. Then the first number after
2 that is not crossed off is a prime number namely 3. Now we cross off all
numbers in the list after 3, that are multiples of three. Then the first number
in the list not yet crossed off is a prime, namely 5, then cross of all numbers
in the list greater than 5 that are multiples of 5. If we continue this process
until any multiple of the last prime is greater than n, then we have found all
the primes in the list.
Eratosthenes of Cyrene (276 to 194 BC), created this Algorithm to find
all prime numbers less than n. Also Eratosthenes was the first to measure the
circumference of the earth and was the head of the library at Alexandria. A
computer algorithm is limited to the largest size integer that can be stored,
commonly to the largest positive 32 bit integer.
A sieve of Eratosthenes program:
// sieve.cpp sieve of eratosthenes of Cyrene (276 to 194 BC)
// Algorithm to find all prime numbers less than n.
// Eratosthenes was the first to measure the
// circumference of the earth. He was the head of the
// library at Alexandria.
// 3/20/2013
// 7/7/97
#include <iostream.h>
main(int argc,char **argv){
const int na=1000000;
char a[na];
int i,k,n,j,m,n1,n2,ik;
int prevp,twinp,twinp1,twinp2;
//All indices of a, where a has value p (p: prime numbers),
//are potential primes.
//Computes all primes <= n
if(argc < 2){
printf("Sieve of Eratosthenes of Cyrene (276 to 194 BC).\n");
printf("This is an Algorithm to find all prime numbers less than n.\n");
printf("Eratosthenes was the first to measure the circumference \n");
printf("of the earth. He was the head of the library at Alexandria.\n");
printf("\n");
44
// n=na-1;
for(i=0;i<n2;i++){
a[i]=p;
}
k=2;
//The k in the while test here is a prime.
while(k < n2){
m=n2/k;
if(m == 1)break;
45
}
}
//Write a newline after 8 prime numbers have been printed.
if(j%8 == 0){
cout << endl;
}
prevp=i;
}
}
cout << " \n Number of primes between " << n1 << " and " << n2 << " = " << j <<
cout << " \n Number of pairs of twin primes between " << n1 << " and " << n2 <<
cout << " \n The last pair of twin primes less than " << n2 << " = " << twinp1<<
return 0;
}
29
Perfect Numbers
A perfect number is a positive integer equal to the sum of its positive divisors,
so the first is 6,
6 = 1 + 2 + 3,
the second is 28,
28 = 1 + 2 + 4 + 7 + 14
The next two are 496 and 8128.
30
Twin Primes
Twin primes are prime numbers differing by two. It is not known if there are
an infinite number of twin primes. This is a famous open problem. Here are
a few twin primes:
3 5
5 7
17 19
29 31
47
41 43
59 61
71 73
101 103
107 109
137 139
149 151
179 181
191 193
227 229
281 283
311 313
347 349
419 421
431 433
461 463
521 523
569 571
599 601
617 619
641 643
809 811
827 829
857 859
881 883
31
Analytic number theory is a subject that uses Real and Complex Analysis
(Calculus) to prove number theoretic theorems such as the prime number
theorem.
48
32
Repeating Decimals
Using long division we know that any fraction or rational number has an infinite decimal representation with eventual repeating decimals. Let us consider
the reverse problem of determining the fraction from the decimal expansion.
We also discussed this above in the section called Decimal Expansions.
We repeat here a similar analysis in a slightly less detailed form.
Let
a = .1234123412341234...
have the four repeating decimals 1234. Show that
a = 1234/9999.
We have
a a/10000 = .1234 = 1234/10000
so
a(1 1/10000) = 1234/10000
So multiplying by 10000
a(10000 1) = 1234,
so
a = 1234/9999.
This can be generalized to the following. If a has n repeating decimals,
d1 d2 d3 ....dn , that is
a = .d1 d2 d3 ....dn d1 d2 d3 ....dn ...,
then
d1 d2 d3 ....dn
,
999...999
where the denominator has n digits, each a 9.
a=
49
33
2
3
19 23
53 59
89 97
131
173
223
263
311
359
409
457
503
569
613
659
719
769
827
881
941
997
1049
1097
1163
1223
1283
1321
1423
1459
1511
1571
1619
1693
1747
1811
1877
1949
2003
2069
2129
2203
2267
2311
2377
2423
2503
2579
2657
2693
2741
2801
2861
5
7
29 31
61 67
101
137
179
227
269
313
367
419
461
509
571
617
661
727
773
829
883
947
1009
1051
1103
1171
1229
1289
1327
1427
1471
1523
1579
1621
1697
1753
1823
1879
1951
2011
2081
2131
2207
2269
2333
2381
2437
2521
2591
2659
2699
2749
2803
2879
11 13
37 41
71 73
103
139
181
229
271
317
373
421
463
521
577
619
673
733
787
839
887
953
1013
1061
1109
1181
1231
1291
1361
1429
1481
1531
1583
1627
1699
1759
1831
1889
1973
2017
2083
2137
2213
2273
2339
2383
2441
2531
2593
2663
2707
2753
2819
2887
17
43 47
79 83
107
149
191
233
277
331
379
431
467
523
587
631
677
739
797
853
907
967
1019
1063
1117
1187
1237
1297
1367
1433
1483
1543
1597
1637
1709
1777
1847
1901
1979
2027
2087
2141
2221
2281
2341
2389
2447
2539
2609
2671
2711
2767
2833
2897
109
151
193
239
281
337
383
433
479
541
593
641
683
743
809
857
911
971
1021
1069
1123
1193
1249
1301
1373
1439
1487
1549
1601
1657
1721
1783
1861
1907
1987
2029
2089
2143
2237
2287
2347
2393
2459
2543
2617
2677
2713
2777
2837
2903
113
157
197
241
283
347
389
439
487
547
599
643
691
751
811
859
919
977
1031
1087
1129
1201
1259
1303
1381
1447
1489
1553
1607
1663
1723
1787
1867
1913
1993
2039
2099
2153
2239
2293
2351
2399
2467
2549
2621
2683
2719
2789
2843
2909
50
127
163
199
251
293
349
397
443
491
557
601
647
701
757
821
863
929
983
1033
1091
1151
1213
1277
1307
1399
1451
1493
1559
1609
1667
1733
1789
1871
1931
1997
2053
2111
2161
2243
2297
2357
2411
2473
2551
2633
2687
2729
2791
2851
2917
167
211
257
307
353
401
449
499
563
607
653
709
761
823
877
937
991
1039
1093
1153
1217
1279
1319
1409
1453
1499
1567
1613
1669
1741
1801
1873
1933
1999
2063
2113
2179
2251
2309
2371
2417
2477
2557
2647
2689
2731
2797
2857
2927
2939
3011
3079
3167
3221
3301
3347
3413
3491
3541
3607
3671
3727
3797
3863
3923
4003
4057
4129
4211
4259
4337
4409
4481
4547
4621
4673
4751
4813
4909
4967
5011
5087
5167
5233
5309
5399
5443
5507
5573
5653
5711
5791
5849
5897
6007
6073
6133
6211
6271
6329
6379
6473
6563
6637
2953
3019
3083
3169
3229
3307
3359
3433
3499
3547
3613
3673
3733
3803
3877
3929
4007
4073
4133
4217
4261
4339
4421
4483
4549
4637
4679
4759
4817
4919
4969
5021
5099
5171
5237
5323
5407
5449
5519
5581
5657
5717
5801
5851
5903
6011
6079
6143
6217
6277
6337
6389
6481
6569
6653
2957
3023
3089
3181
3251
3313
3361
3449
3511
3557
3617
3677
3739
3821
3881
3931
4013
4079
4139
4219
4271
4349
4423
4493
4561
4639
4691
4783
4831
4931
4973
5023
5101
5179
5261
5333
5413
5471
5521
5591
5659
5737
5807
5857
5923
6029
6089
6151
6221
6287
6343
6397
6491
6571
6659
2963
3037
3109
3187
3253
3319
3371
3457
3517
3559
3623
3691
3761
3823
3889
3943
4019
4091
4153
4229
4273
4357
4441
4507
4567
4643
4703
4787
4861
4933
4987
5039
5107
5189
5273
5347
5417
5477
5527
5623
5669
5741
5813
5861
5927
6037
6091
6163
6229
6299
6353
6421
6521
6577
6661
2969
3041
3119
3191
3257
3323
3373
3461
3527
3571
3631
3697
3767
3833
3907
3947
4021
4093
4157
4231
4283
4363
4447
4513
4583
4649
4721
4789
4871
4937
4993
5051
5113
5197
5279
5351
5419
5479
5531
5639
5683
5743
5821
5867
5939
6043
6101
6173
6247
6301
6359
6427
6529
6581
6673
2971
3049
3121
3203
3259
3329
3389
3463
3529
3581
3637
3701
3769
3847
3911
3967
4027
4099
4159
4241
4289
4373
4451
4517
4591
4651
4723
4793
4877
4943
4999
5059
5119
5209
5281
5381
5431
5483
5557
5641
5689
5749
5827
5869
5953
6047
6113
6197
6257
6311
6361
6449
6547
6599
6679
51
2999
3061
3137
3209
3271
3331
3391
3467
3533
3583
3643
3709
3779
3851
3917
3989
4049
4111
4177
4243
4297
4391
4457
4519
4597
4657
4729
4799
4889
4951
5003
5077
5147
5227
5297
5387
5437
5501
5563
5647
5693
5779
5839
5879
5981
6053
6121
6199
6263
6317
6367
6451
6551
6607
6689
3001
3067
3163
3217
3299
3343
3407
3469
3539
3593
3659
3719
3793
3853
3919
4001
4051
4127
4201
4253
4327
4397
4463
4523
4603
4663
4733
4801
4903
4957
5009
5081
5153
5231
5303
5393
5441
5503
5569
5651
5701
5783
5843
5881
5987
6067
6131
6203
6269
6323
6373
6469
6553
6619
6691
6701
6779
6833
6907
6971
7027
7121
7207
7253
7349
7457
7517
7561
7621
7691
7757
7853
7919
8009
8087
8161
8231
8291
8369
8443
8537
8609
8677
8731
8803
8861
8941
9011
9091
9161
9227
9311
9377
9433
9491
9587
9649
9733
9791
9857
9929
34
6703
6781
6841
6911
6977
7039
7127
7211
7283
7351
7459
7523
7573
7639
7699
7759
7867
7927
8011
8089
8167
8233
8293
8377
8447
8539
8623
8681
8737
8807
8863
8951
9013
9103
9173
9239
9319
9391
9437
9497
9601
9661
9739
9803
9859
9931
6709
6791
6857
6917
6983
7043
7129
7213
7297
7369
7477
7529
7577
7643
7703
7789
7873
7933
8017
8093
8171
8237
8297
8387
8461
8543
8627
8689
8741
8819
8867
8963
9029
9109
9181
9241
9323
9397
9439
9511
9613
9677
9743
9811
9871
9941
6719
6793
6863
6947
6991
7057
7151
7219
7307
7393
7481
7537
7583
7649
7717
7793
7877
7937
8039
8101
8179
8243
8311
8389
8467
8563
8629
8693
8747
8821
8887
8969
9041
9127
9187
9257
9337
9403
9461
9521
9619
9679
9749
9817
9883
9949
6733
6803
6869
6949
6997
7069
7159
7229
7309
7411
7487
7541
7589
7669
7723
7817
7879
7949
8053
8111
8191
8263
8317
8419
8501
8573
8641
8699
8753
8831
8893
8971
9043
9133
9199
9277
9341
9413
9463
9533
9623
9689
9767
9829
9887
9967
6737
6823
6871
6959
7001
7079
7177
7237
7321
7417
7489
7547
7591
7673
7727
7823
7883
7951
8059
8117
8209
8269
8329
8423
8513
8581
8647
8707
8761
8837
8923
8999
9049
9137
9203
9281
9343
9419
9467
9539
9629
9697
9769
9833
9901
9973
6761
6827
6883
6961
7013
7103
7187
7243
7331
7433
7499
7549
7603
7681
7741
7829
7901
7963
8069
8123
8219
8273
8353
8429
8521
8597
8663
8713
8779
8839
8929
9001
9059
9151
9209
9283
9349
9421
9473
9547
9631
9719
9781
9839
9907
6763
6829
6899
6967
7019
7109
7193
7247
7333
7451
7507
7559
7607
7687
7753
7841
7907
7993
8081
8147
8221
8287
8363
8431
8527
8599
8669
8719
8783
8849
8933
9007
9067
9157
9221
9293
9371
9431
9479
9551
9643
9721
9787
9851
9923
Fibonacci Numbers
See Jim Emery Fibonacci Numbers and the Golden Ratio, fibonacci.tex,
fibonacci.pdf .
52
35
36
Bibliography
53