BlueBook - 10 Primes on a Line

View as PDF

Points: 5
Time limit: 1.0s
Memory limit: 16M

Problem types
BlueBook

A natural number (greater than one), is a prime number if it has no natural number divisors other than and . Given an integer , write a program that finds the first primes, printing them ten to a line. Each number should be separated by a space.

Sample Input

5

Sample Output

2 3 5 7 11

• commented on April 26, 2024, 6:43 p.m.

man how do i do this

• commented on April 26, 2024, 6:43 p.m.

do i use a jittelang or a fukalatogan

• commented on April 26, 2024, 6:43 p.m.

jittleyang

• commented on April 26, 2024, 6:42 p.m.

This was a very cool problem!

• commented on Dec. 29, 2020, 1:38 a.m. edited

Hi. what is the max value of . I passed 2 out of 3 sets. I'm using sieve to solve this. My code.

• commented on Dec. 29, 2020, 2:36 a.m.

Your sieve sieves up to 1e6, but it only inserts primes up to the square root of that. You could either change the sieve size or just put another for loop after it to insert primes, instead of doing it both at once.

• commented on Dec. 29, 2020, 4:16 a.m. edited

thank you so much! I added a for loop to add more primes and it passed :D thanks, aegirwang !