Question: Data Structures and Algorithms question. A prime number is a positive integer other than 1 and is divisible only by 1 and itself. For example,
A prime number is a positive integer other than 1 and is divisible only by 1 and itself. For example, 7 is a prime number because the only positive factors of 7 are 1 and 7. On the other hand, 12 is not a prime number because 2, 3, 4, and 6 are also factors of 12. You are asked to write a function to compute the prime numbers up to a given value. The function is named sieve and it will take an integer n as parameter. The function should return a list that contains all prime numbers up to (and including, if appropriate) n, the numbers in the returned list must be in ascending order. def sieve (n)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
