Counting Primes
InterviewTime limit2sMemory limit128 MB
Count how many of up to 100 given numbers (each at most 1000) are prime.
- Level
Easy2 of 10
- Topics
- Math, Brute force
- Solved
- No attempts yet
Problem
Given N natural numbers, count how many of them are prime and print the count.
A prime is a natural number greater than 1 that is divisible only by 1 and itself.
Input
The first line contains N, the number of values. N is at most 100.
The next input contains N natural numbers separated by whitespace. Each value is at most 1,000.
Output
Print the number of prime values among the given numbers.