Advertisement
Marin171

JS

Sep 29th, 2022
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. function solve(input) {
  2. let n = Number(input[0]);
  3. let output = "";
  4.  
  5. for (let i = 1111; i <= 9999; i++) {
  6. let numberAsString = i.toString();
  7. for (let index = 0; index < numberAsString.length; index++) {
  8. let currentNum = Number(numberAsString[index]);
  9. if (i % currentNum !== 0) {
  10. break;
  11. }
  12. if (index === 3 && i % currentNum === 0) {
  13. output += i + " ";
  14. }
  15. }
  16. }
  17. console.log(output);
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement