Divisibility

PHOTO EMBED

Sat Apr 30 2022 01:37:00 GMT+0000 (Coordinated Universal Time)

Saved by @GreenMark #javascript

// Divisibility
// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
   main(stdin_input);
});

function main(input) {
    var data= input.toString().split("\n");

    process.stdout.write(divisible(data[1], parseInt(data[0])));
           // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail



// Write your code here
// Sample code to perform I/O:
//Enter your code here

function divisible(input,n) {
   

    const arr = input.split(" ");
    
    let number="";
    for (let i=0; i<n; i++) {
       
        number=number+arr[i].substr(arr[i].length-1,1);

    } 

    
    if (parseInt(number.substr(number.length-1,1))!=0) {
        return "No";
    } else { return "Yes";}
    
 

}
content_copyCOPY

Problem You are provided an array of size that contains non-negative integers. Your task is to determine whether the number that is formed by selecting the last digit of all the N numbers is divisible by . Note: View the sample explanation section for more clarification. Input format First line: A single integer denoting the size of array Second line: space-separated integers. Output format If the number is divisible by , then print . Otherwise, print . Constraints Sample Input 5 85 25 65 21 84 Sample Output No Time Limit: 1 Memory Limit: 256 Source Limit: Explanation Last digit of is . Last digit of is . Last digit of is . Last digit of is . Last digit of is . Therefore the number formed is which is not divisible by .

https://www.hackerearth.com/practice/basic-programming/input-output/basics-of-input-output/practice-problems/algorithm/divisible-or-not-81b86ad7/