Confirming your payment

Skip to content

The World of Algorithms · Question 13 of 15

Write an algorithm prime(n) to check if n is prime.

Question 133 marksMedium

Write an algorithm prime(n)\text{prime}(n) to check if nn is prime.

(Hint: A prime number pp has exactly two distinct factors, 1 and pp. Can you make use of divisors(n)\text{divisors}(n) to write out prime(n)\text{prime}(n)?)