Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function divideWithoutRemainder(input) {
- let numbers = Number(input.shift());
- let p1 = 0;
- let p2 = 0;
- let p3 = 0;
- for (let n = 1; n <= numbers; n++) {
- let currentNumber = Number(input.shift());
- if(currentNumber % 2 === 0) {
- p1++;
- }
- if(currentNumber % 3 === 0) {
- p2++;
- }
- if(currentNumber % 4 === 0) {
- p3++;
- }
- }
- let p1Percent = p1 / numbers * 100;
- let p2Percent = p2 / numbers * 100;
- let p3Percent = p3 / numbers * 100;
- console.log(`${p1Percent.toFixed(2)}%`);
- console.log(`${p2Percent.toFixed(2)}%`);
- console.log(`${p3Percent.toFixed(2)}%`);
- }
Add Comment
Please, Sign In to add comment