Control C501A P16425


Statement
 

pdf   zip

thehtml

Your task is to write a program that, for each n given, prints the n smallest first prime numbers.

Input

The input is a sequence of natural numbers n with 1 ≤ n ≤ 1000.

Output

For each n, print a line with the n first prime numbers, in increasing order, and separated by a comma.

Observation

Before reading any n, do a sieve of Eratosthenes to precalculate the first 1000 prime numbers. Knowing that 7919 is the prime number 1000 could be useful.

Public test cases
  • Input

    5
    10
    1
    29
    

    Output

    2,3,5,7,11
    2,3,5,7,11,13,17,19,23,29
    2
    2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109
    
  • Information
    Author
    Professorat de P1
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++ Python