-Enigmos-

specialNumbers.js

Dec 9th, 2021
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function specialNumbers(input) {
  2.     let index = 0;
  3.     let n = Number(input[index]);
  4.     index++;
  5.     let result = "";
  6.  
  7.     for (let i = 1111; i < 9999; i++) {
  8.         let currentNum = "" + i;
  9.         let specialNumber = false;
  10.         for (let i1 = 0; i1 < currentNum.length; i1++) {
  11.             let currentInt = Number(currentNum[i1]);
  12.             if (n % currentInt === 0) {
  13.                 specialNumber = true;
  14.             } else {
  15.                 specialNumber = false;
  16.                 break;
  17.             }
  18.         }
  19.         if (specialNumber) {
  20.             result += "" + currentNum + " ";
  21.         }
  22.     }
  23.     console.log(result);
  24. }
  25.  
  26. specialNumbers(["3"]);
Advertisement
Add Comment
Please, Sign In to add comment