Comp Security Assignment 1
Comp Security Assignment 1
ak=b
bc=akc
Hence: a|bc
ak=b
bs=c
aks=c
Hence a|c
2. Using any programming language of choice (preferably python), implement the following
algorithms
def SieveOfEratosthenes(x):
prime = [True for i in range(x + 1)]
p = 2
while (p * p <= x):
if (prime[p] == True):
for i in range(p * 2, x + 1, p):
prime[i] = False
p += 1
SCT212-0047/2018
VICTOR KIMARU KIPLIMO
C.T 3.1
ASSIGNMENT 1
BCT 2306: FUNDAMENTALS OF COMPUTER SECURITY TECHNOLOGY
prime[0]= False
prime[1]= False
for p in range(n + 1):
if prime[p]:
print p
3. Let m be the gcd of 117 and 299. Find m using the Euclidean algorithm (5 marks)
299 = 117.2 + 65
117 = 65.1 + 52
65 = 52.1 + 13
52 = 13.4 + 0
=> 13
if z: print('gcd is %s' % x)
return x
5. Modify the Euclidean Algorithm above such that it not only returns the gcd of a and b but also
the Bezouts coefficients x and y, such that 𝑎𝑥+𝑏𝑦=1 (10 marks)
7 =1.7 +0 p=9
GCD = 1 q = -127
7. Determine whether the equation 486𝑥+222𝑦=6 has a solution such that 𝑥,𝑦∈𝑍𝑝 If yes, find x and
y. If not, explain your answer. (5 marks)
12 = 6.2 + 0 x = 16
GCD = 6 y = -35
2 = 1. 2 + 0 x=4
GCD = 1 y = -153
SCT212-0047/2018
VICTOR KIMARU KIPLIMO
C.T 3.1
ASSIGNMENT 1
BCT 2306: FUNDAMENTALS OF COMPUTER SECURITY TECHNOLOGY