Back

Array In Codekata

Created 3 years ago
374 Views
1 Comments
KarthickT
@KarthickT
KarthickT
@KarthickTProfile is locked. Login

you are given with array of numbers. you have to find whether array is beautiful or not. A beautiful array is an array whose sum of all numbers is divisible by 2, 3 and 5

Input Description:
You are given a number ‘n’ denoting the size of array. Next line contains n space separated numbers.

Output Description:0
Print 1 if array is beautiful and 0 if it is not

Sample Input :
5
5 25 35 -5 30
Sample Output :
1

I have tried below one but I'm not getting the output in codekata. Give an idea to do this. Also please explain how can I limit my array to given input n.

a=int(input())

c=[]

sum=0

for i in range(1,a+1):

b=int(input())

c.append(b)

for i in c:

sum=sum+i

if sum%2==0 and sum%3==0 and sum%5==0:

print(1)

else:

print(0)

Comments
Please login to comment.