Advertisement
Spocoman

05. Special Numbers

Dec 31st, 2021 (edited)
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function specialNumbers(input) {
  2.     let num = Number(input[0]);
  3.     let specialNumbers = "";
  4.     for (let i = 1111; i < 10000; i++) {
  5.         let isSpecial = true;
  6.         for (let j = 0; j < 4; j++) {
  7.             if (num % Number(i.toString()[j]) !== 0) {
  8.                 isSpecial = false;
  9.                 break;
  10.             }
  11.         }
  12.         if (isSpecial) {
  13.             specialNumbers += `${i} `;
  14.         }
  15.     }
  16.     console.log(specialNumbers);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement