Advertisement
Liliana797979

viarno reshenie division without remainder

Feb 13th, 2021
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             function divisionWithoutRemainder(input) {
  2.                 let n = Number(input[0]);
  3.  
  4.                 p1 = 0;
  5.                 p2 = 0;
  6.                 p3 = 0;
  7.  
  8.                 p1percentage = 0;
  9.                 p2percentage = 0;
  10.                 p3percentage = 0;
  11.  
  12.                 for (let i = 1; i <= n; i++) {
  13.                     let currentNum = Number(input[i]);
  14.                     if (currentNum % 2 === 0) {
  15.                         p1++;
  16.                     }
  17.                     if (currentNum % 3 === 0) {
  18.                         p2++;
  19.                     }
  20.                     if (currentNum % 4 === 0) {
  21.                         p3++;
  22.                     }
  23.                 }
  24.                     p1percentage = (p1 / n * 100).toFixed(2);
  25.                     p2percentage = (p2 / n * 100).toFixed(2);
  26.                     p3percentage = (p3 / n * 100).toFixed(2);
  27.  
  28.                
  29.            
  30.             console.log(p1percentage + "%");
  31.             console.log(p2percentage + "%");
  32.             console.log(p3percentage + "%");
  33.                 }  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement