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
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
Sample Input : 5 5 25 35 -5 30
Sample Output : 1
const readline = require('readline');
const inp = readline.createInterface({
input: process.stdin
});
const userInput = [];
inp.on("line", (data) => {
userInput.push(data);
});
inp.on("close", () =>
{var a = (userInput[0]);
var b =(userInput[1]);
var arr = b.split(" ").map(val=>Number(val))
var sum=0
var ans=false;
for(i=0;i<arr.length;i++)
{sum=sum+arr[i]}
if((sum%2==0)&&(sum%3==0)&&(sum%5==0))
console.log(1)
else
console.log(0);
});
Comments
Post a Comment