Advertisement
zarkoto223

Untitled

Mar 28th, 2024
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function asd(input) {
  2.   let n = Number(input[0]);
  3.   let flag = true;
  4.  
  5.   for (let a = 1; a <= 9; a++) {
  6.     if (flag === false) {
  7.       break;
  8.     }
  9.  
  10.     for (let b = 9; b >= a; b--) {
  11.       if (flag === false) {
  12.         break;
  13.       }
  14.       for (let c = 0; c <= 9; c++) {
  15.         if (flag === false) {
  16.           break;
  17.         }
  18.  
  19.         for (let d = 9; d > c; d--) {
  20.           if (a * b * c * d === a + b + c + d && n % 10 === 5) {
  21.             console.log(`${a}${b}${c}${d}`);
  22.  
  23.             flag = false;
  24.             break;
  25.           } else if (
  26.             Math.floor((a * b * c * d) / (a + b + c + d)) === 3 &&
  27.             n % 3 === 0
  28.           ) {
  29.             console.log(`${d}${c}${b}${a}`);
  30.             flag = false;
  31.             break;
  32.           } else {
  33.             continue;
  34.           }
  35.         }
  36.       }
  37.     }
  38.   }
  39.   if (flag === true) {
  40.     console.log("Nothing found");
  41.   }
  42. }
  43. asd(["123"]);
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement