Advertisement
Spocoman

Number Generator

Sep 25th, 2023
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function numberGenerator(input) {
  2.     let m = Number(input[0]);
  3.     let n = Number(input[1]);
  4.     let l = Number(input[2]);
  5.     let special = Number(input[3]);
  6.     let control = Number(input[4]);
  7.  
  8.     for (let i = m; i > 0; i--) {
  9.         for (let j = n; j > 0; j--) {
  10.             for (let k = l; k > 0; k--) {
  11.                 let num = i * 100 + j * 10 + k;
  12.  
  13.                 if (num % 3 == 0) {
  14.                     special += 5;
  15.                 } else if (num % 5 == 0) {
  16.                     special -= 2;
  17.                 } else if (num % 2 == 0) {
  18.                     special *= 2;
  19.                 }
  20.  
  21.                 if (special >= control) {
  22.                     console.log(`Yes! Control number was reached! Current special number is ${special}.`);
  23.                     return;
  24.                 }
  25.             }
  26.         }
  27.     }
  28.     console.log(`No! ${special} is the last reached special number.`);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement