Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function divide(args) {
- let numberCount = Number(args[0]);
- let divisibleBy2 = 0;
- let divisibleBy3 = 0;
- let divisibleBy4 = 0;
- let currentNumber = 0;
- for(i = 1; i <= numberCount; i++){
- let currentNumber = Number(args[i]);
- if(currentNumber % 4 == 0) {
- divisibleBy4++;
- }
- if(currentNumber % 3 == 0) {
- divisibleBy3++;
- }
- if(currentNumber % 2 == 0) {
- divisibleBy2++;
- }
- }
- console.log((((divisibleBy2) / numberCount) * 100).toFixed(2) + " %");
- console.log((((divisibleBy3) / numberCount) * 100).toFixed(2) + " %");
- console.log((((divisibleBy4) / numberCount) * 100).toFixed(2) + " %");
- }
- divide([10, 680, 2, 600, 200, 800, 799, 199, 46, 128, 65]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement