Learn
Exam

Count Specific Elements in Array 2

Difficulty
STARTER

Problem

Given an array numbers of natural number elements, write a function solution that returns the count of prime numbers in numbers. (A prime number is defined as a natural number greater than 1 that has only 1 and itself as divisors.)


Constraints

  • Each element in numbers is a natural number between 2 and 500.
  • numbers is not empty, and its length does not exceed 100.

Test Case

Test Case Number numbers return
1 [2, 3, 4, 5] 3
2 [100, 200, 300] 0
3 [21, 47, 33, 51, 60, 99] 1

Explanation for Test Case 1

  • The prime numbers in numbers are 2, 3, and 5, so the count is 3.

Explanation for Test Case 2

  • There are no prime numbers in numbers, so the return value is 0.

Explanation for Test Case 3

  • The prime number in numbers is 47, so the count is 1.