1.3#

Exercises from Humphreys, J. F. & M. Y. Prest. (2008). Numbers, Groups, and Codes. 2nd Ed. Cambridge University Press.


Table of Contents#


Programming Environment#

import math
import numpy as np

1#

Use the Sieve of Eratosthenes to find all prime numbers less than 250.

math.sqrt(250)
15.811388300841896
integers = list(range(2, 250 + 1))
primes   = []

print(primes)
print(np.array(integers))
[]
[  2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37
  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55
  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73
  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91
  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109
 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250]
prime    = integers.pop(0)
primes.append(prime)
integers = list(integer for integer in integers if integer % prime != 0)

print(primes)
print(np.array(integers))
[2]
[  3   5   7   9  11  13  15  17  19  21  23  25  27  29  31  33  35  37
  39  41  43  45  47  49  51  53  55  57  59  61  63  65  67  69  71  73
  75  77  79  81  83  85  87  89  91  93  95  97  99 101 103 105 107 109
 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145
 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177 179 181
 183 185 187 189 191 193 195 197 199 201 203 205 207 209 211 213 215 217
 219 221 223 225 227 229 231 233 235 237 239 241 243 245 247 249]
prime    = integers.pop(0)
primes.append(prime)
integers = list(integer for integer in integers if integer % prime != 0)

print(primes)
print(np.array(integers))
[2, 3]
[  5   7  11  13  17  19  23  25  29  31  35  37  41  43  47  49  53  55
  59  61  65  67  71  73  77  79  83  85  89  91  95  97 101 103 107 109
 113 115 119 121 125 127 131 133 137 139 143 145 149 151 155 157 161 163
 167 169 173 175 179 181 185 187 191 193 197 199 203 205 209 211 215 217
 221 223 227 229 233 235 239 241 245 247]
prime    = integers.pop(0)
primes.append(prime)
integers = list(integer for integer in integers if integer % prime != 0)

print(primes)
print(np.array(integers))
[2, 3, 5]
[  7  11  13  17  19  23  29  31  37  41  43  47  49  53  59  61  67  71
  73  77  79  83  89  91  97 101 103 107 109 113 119 121 127 131 133 137
 139 143 149 151 157 161 163 167 169 173 179 181 187 191 193 197 199 203
 209 211 217 221 223 227 229 233 239 241 247]
prime    = integers.pop(0)
primes.append(prime)
integers = list(integer for integer in integers if integer % prime != 0)

print(primes)
print(np.array(integers))
[2, 3, 5, 7]
[ 11  13  17  19  23  29  31  37  41  43  47  53  59  61  67  71  73  79
  83  89  97 101 103 107 109 113 121 127 131 137 139 143 149 151 157 163
 167 169 173 179 181 187 191 193 197 199 209 211 221 223 227 229 233 239
 241 247]
prime    = integers.pop(0)
primes.append(prime)
integers = list(integer for integer in integers if integer % prime != 0)

print(primes)
print(np.array(integers))
[2, 3, 5, 7, 11]
[ 13  17  19  23  29  31  37  41  43  47  53  59  61  67  71  73  79  83
  89  97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 169 173
 179 181 191 193 197 199 211 221 223 227 229 233 239 241 247]
prime    = integers.pop(0)
primes.append(prime)
integers = list(integer for integer in integers if integer % prime != 0)

print(primes)
print(np.array(integers))
[2, 3, 5, 7, 11, 13]
[ 17  19  23  29  31  37  41  43  47  53  59  61  67  71  73  79  83  89
  97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181
 191 193 197 199 211 223 227 229 233 239 241]
print(np.array(primes + integers))
[  2   3   5   7  11  13  17  19  23  29  31  37  41  43  47  53  59  61
  67  71  73  79  83  89  97 101 103 107 109 113 127 131 137 139 149 151
 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241]

2#

Show why, when using the sieve method to find all primes less than n, you need only strike out multiples of the primes whose square is less than or equal to n.

Claim

Each composite up to n has a prime factor less than or equal to n.

nP[Composite(n)p{2,3,5,,n}(pn)]

Proof

Let n be composite.
Then n has a factor 1<a<n.
anab=n for some positive integer b.
1<a<nb<(ab=n)<nb
b<abb<n
n<nb1<b
1<b<n

Let a>n and b>n.
Then ab>nn=n. Contradiction!
So either an or bn or both.
ALTERNATIVELY
So either an or an or both.

Let an.
an1a1nna=bn=nn.
anbn.

Let an.
an1a1nna=bn=nn.
anbn.

Therefore either an or bn or both.
n has a positive divisor not exceeding n since both a and b are divisors of n.
This divisor is either prime or, by the fundamental theorem of arithmetic, has a prime divisor less than itself.
In either case, n has a prime divisor less than or equal to n.

n2nn2121=1212122=12+122123=221=12+1+122224=22=(121)+2+222225=22+1=(121)+2+2+132226=22+232227=22+332228=321=22+2+232329=32=(221)+3+3323210=32+1=(221)+3+3+142142224=1521=142+14+14152152225=152=(1421)+15+15152152226=152+1=(1421)+15+15+1162152250=152+25=(1421)+15+15+25162152255=1621=152+15+15162162256=162=(1521)+16+16162162257=162+1=(1521)+16+16+1172162288=1721=162+16+16172172289=172=(1621)+17+17172172290=172+1=(1621)+17+17+1182

MathJax internal buffer size exceeded; is there a recursive macro call?

3#

(a) Find the prime factorizations for the following integers (a calculator will be useful for the larger values): 136, 150, 255, 713, 3549, 4591. (b) Use your answers to find the greatest common divisor and least common multiple for each of the pairs: 136 and 150, 255 and 3549.

136=23×30×50×70×110×130×171×190×230×290×310150=21×31×52×70×110×130×170×190×230×290×310255=20×31×51×70×110×130×171×190×230×290×310713=20×30×50×70×110×130×170×190×231×290×3113549=20×31×50×71×110×132×170×190×230×290×3104591=20×30×50×70×110×130×170×190×230×290×310××45911
136=23×30×50×70×110×130×171×190×230×290×310150=21×31×52×70×110×130×170×190×230×290×310gcd(136,150)=21×30×50×70×110×130×170×190×230×290×310=2lcm(136,150)=23×31×52×70×110×130×171×190×230×290×310=10,200
a = 136
b = 150
print(np.gcd(a, b))
print(np.lcm(a, b))
2
10200
255=20×31×51×70×110×130×171×190×230×290×3103549=20×31×50×71×110×132×170×190×230×290×310gcd(255,3549)=20×31×50×70×110×130×170×190×230×290×310=3lcm(255,3549)=20×31×51×71×110×132×171×190×230×290×310=301,665
a = 255
b = 3549
print(np.gcd(a, b))
print(np.lcm(a, b))
3
301665

4#

Let p1=2,p2=3, be the list of primes, in increasing order. Consider products of the form (p1×p2××pn)+1. Show that this number is prime for n=1,,5. Show that when n=6 this number is not prime. [Use your answer to #1. A calculator will speed the work of checking divisibility.]

n=1(p1)+1=(2)+1=3n=2(p1×p2)+1=(2×3)+1=7n=3(p1×p2×p3)+1=(2×3×5)+1=31n=4(p1×p2×p3×p4)+1=(2×3×5×7)+1=211n=5(p1×p2×p3×p4×p5)+1=(2×3×5×7×11)+1=2311n=6(p1×p2×p3×p4×p5×p6)+1=(2×3×5×7×11×13)+1=30031=59×509

5#

By considering the prime decomposition of gcd(ab,n), show that if a, b, and n are integers with n relatively prime to each of a and b, then n is relatively prime to ab.

a=p1s1×p2s2××prsrb=p1t1×p2t2××prtrab=p1s1+t1×p2s2+t2××prsr+tr