Advertisement
angelstoev

Задача: делене без остатък(на 2, 3, 4)

Sep 4th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function divide(args) {
  2.     let numberCount = Number(args[0]);
  3.     let divisibleBy2 = 0;
  4.     let divisibleBy3 = 0;
  5.     let divisibleBy4 = 0;
  6.     let currentNumber = 0;
  7.     for(i = 1; i <= numberCount; i++){
  8.         let currentNumber = Number(args[i]);
  9.    
  10.     if(currentNumber % 4 == 0) {
  11.         divisibleBy4++;
  12.     }
  13.      if(currentNumber % 3 == 0) {
  14.         divisibleBy3++;
  15.     }
  16.     if(currentNumber % 2 == 0) {
  17.         divisibleBy2++;
  18.     }
  19. }
  20.     console.log((((divisibleBy2) / numberCount) * 100).toFixed(2) + " %");
  21.     console.log((((divisibleBy3) / numberCount) * 100).toFixed(2) + " %");
  22.     console.log((((divisibleBy4) / numberCount) * 100).toFixed(2) + " %");
  23. }
  24. divide([10, 680, 2, 600, 200, 800, 799, 199, 46, 128, 65]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement