Advertisement
Spocoman

Division Without Remainder

Feb 13th, 2022 (edited)
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function divideWithoutRemainder(input) {
  2.     let n = parseInt(input[0]),
  3.         number, p1 = 0, p2 = 0, p3 = 0;
  4.        
  5.     for (let i = 1; i <= n; i++) {
  6.         number = Number(input[i]);
  7.         if (number % 2 === 0) {
  8.             p1++;
  9.         }
  10.         if (number % 3 === 0) {
  11.             p2++;
  12.         }
  13.         if (number % 4 === 0) {
  14.             p3++;
  15.         }
  16.     }
  17.    
  18.     console.log(`${(p1 / n * 100).toFixed(2)}%`);
  19.     console.log(`${(p2 / n * 100).toFixed(2)}%`);
  20.     console.log(`${(p3 / n * 100).toFixed(2)}%`);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement