aWrite a pseudo code for an algorithm that finds all prime n
a)Write a pseudo code for an algorithm that finds all prime numbers that are less than or equal to n.
b)Analyze the worst-case time complexity of your algorithm in (1) by using Big-O notation. Show steps.
Solution
Pseudo-Code:
Get Num
for i= 2 to NUM
for j=2 to i-1
if i % j = 0
break
end if
if j = i then Print i //(it is prime)
end if
end for
end for
B. The worst case is when the number is too big. we need two loops to acomplish this so the complexity is O(n2) as these are nested loops.

