MartenBG

6-ta

Feb 25th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. function numbers(input) {
  2. let n = String(input[0]);
  3. let firstDigit = Number(n[0]);
  4. let secondDigit = Number(n[1]);
  5. let thirdDigit = Number(n[2]);
  6. let rows = firstDigit + secondDigit;
  7. let columns = firstDigit + thirdDigit;
  8. let count = rows * columns;
  9. let output = '';
  10. while (count > 0) {
  11. if (n % 5 == 0) {
  12. n -= firstDigit;
  13. } else if (n % 3 == 0) {
  14. n -= secondDigit;
  15. } else {
  16. n += thirdDigit;
  17. }
  18. count--;
  19. output += `${n} `;
  20. }
  21. console.log(output); // columns * rows????
  22. }
  23. numbers([132]);
Advertisement
Add Comment
Please, Sign In to add comment