As a newbie programmer

Dr. Primo visits ArrayCon @ Dcoder

Dcoder icon

Problem: Dr. Primo is a famous mathematician in Codeland. He is known to have numbers as his friends. He is especially in love with Prime Numbers. He goes to the city festival ArrayCon. Every time he is given an array, he tells how many prime numbers are present in the array in few seconds. You will be given an array filled with positive integers, print the response of Dr. Primo, i.e, print how many prime numbers exist in the array.

Input: First line contains N, the size of the array A.

Next line contains N space separated integers.

Output: Print the number of prime numbers in the array

Constraints: 1 ≤ N ≤ 1000

1 ≤ A[i] ≤ 10^8

Sample Input: 5

1 2 3 4 5

Sample Output: 

3

input()
arr = map(int, input().split())
c = 0
for a in arr:
  if a == 1:
    continue
  for i in range(2, int(a**.5) + 1):
    if a % i == 0:
      break
  else:
    c += 1
print(c)

How do you rate this article?

2


Lochard
Lochard

20240228 Arrived in the UK for about 2 week. All my fears persist. Some are even getting worse. https://github.com/locharp/asylum_diary/


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Publish0x Publish0x

Reward the author with $0.01 in crypto, and earn yourself as you read!

20% to author / 80% to me.
Rewards are FREE. Publish0x pays them, not you.

Page not displaying correctly?