#C12337. Sieve of Eratosthenes: Find Primes Less Than N

    ID: 41753 Type: Default 1000ms 256MiB

Sieve of Eratosthenes: Find Primes Less Than N

Sieve of Eratosthenes: Find Primes Less Than N

Given an input value n, output all the prime numbers strictly less than n using the Sieve of Eratosthenes algorithm. If the input is not a valid integer or if n is less than or equal to 2, output an empty list [].

Examples:

  • Input: 10 Output: [2, 3, 5, 7]
  • Input: 20 Output: [2, 3, 5, 7, 11, 13, 17, 19]

Note: You must read from standard input (stdin) and write to standard output (stdout). All formulas, if any, are rendered using LaTeX (for example, the condition for prime is rendered as $n \le 2$ where needed).

inputFormat

A single line containing a value that should represent an integer, n.

outputFormat

A list of prime numbers less than n printed in Python list format. If the input is invalid or n is less than or equal to 2, print an empty list, i.e., [].## sample

10
[2, 3, 5, 7]