## BlueBook - Prime

View as PDF

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

Problem types
##### BlueBook

Given integers , output 1 if each one is prime, and 0 otherwise.

Remember: an integer is prime iff (if and only if) it has exactly two divisors: and .

#### Input Specification

Line : one integer
Lines : one integer

#### Output Specification

Lines : One integer 1 or 0 denoting whether is prime. Output 1 if is prime, and 0 otherwise.

#### Sample Input

3
1
2
3

#### Sample Output

0
1
1

• commented on March 6, 2022, 7:42 p.m.

I am using Python 3 and I got a TLE, I used PyPy 3 and it says it is "failed initializing" someone help

• commented on March 9, 2022, 10:21 p.m.

Failed initializing is probably because you ran out of memory. Pypy uses a lot of memory.

• commented on March 7, 2022, 12:53 p.m.

My assumption for you getting TLE is that you have iterated through each number in the test case. There is a faster way to test if a number is prime.

• commented on March 8, 2022, 12:12 a.m.

I will look into that