Advertisement
Spocoman

04. Car Number

Jan 1st, 2022 (edited)
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function carNumbers(input) {
  2.     let startNum = Number(input[0]);
  3.     let finalNum = Number(input[1]);
  4.     let print = '';
  5.     for (let i = startNum; i <= finalNum; i++) {
  6.         for (let k = startNum; k <= finalNum; k++) {
  7.             for (let j = startNum; j <= finalNum; j++) {
  8.                 for (let x = startNum; x <= finalNum; x++) {
  9.                     if ((i % 2 === 0 && x % 2 === 1 || i % 2 === 1 && x % 2 === 0)
  10.                         && i > x && (k + j) % 2 === 0) {
  11.                         print += `${i}${k}${j}${x} `;
  12.                     }
  13.                 }
  14.             }
  15.         }
  16.     }
  17.     console.log(print);
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement