Count Multiples of 7
Python
Easy
3 views
Problem Description
Read n integers. Count how many are divisible by 7 and output the count.
Input Format
First line n. Second line n integers.
Output Format
One integer count.
Official Solution
import sys
p=sys.stdin.read().strip().split()
if not p: sys.exit(0)
n=int(p[0])
nums=list(map(int,p[1:1+n]))
c=0
for x in nums:
if x%7==0:
c+=1
sys.stdout.write(str(c))
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!