Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function divisionWithoutRemainder(input) {
- let n = Number(input[0]);
- let index = 1;
- let divisibleBy2 = 0;
- let divisibleBy3 = 0;
- let divisibleBy4 = 0;
- for (let i = 1; i <= n; i++) {
- let currentNumber = Number(input[index]);
- index++;
- if (currentNumber % 2 === 0) {
- divisibleBy2++;
- }
- if (currentNumber % 3 === 0) {
- divisibleBy3++;
- }
- if (currentNumber % 4 === 0) {
- divisibleBy4++;
- }
- }
- console.log(`${(divisibleBy2 / n * 100).toFixed(2)}%`);
- console.log(`${(divisibleBy3 / n * 100).toFixed(2)}%`);
- console.log(`${(divisibleBy4 / n * 100).toFixed(2)}%`);
- }
Advertisement
Add Comment
Please, Sign In to add comment