Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function numberGenerator(input) {
- let m = Number(input[0]);
- let n = Number(input[1]);
- let l = Number(input[2]);
- let special = Number(input[3]);
- let control = Number(input[4]);
- for (let i = m; i > 0; i--) {
- for (let j = n; j > 0; j--) {
- for (let k = l; k > 0; k--) {
- let num = i * 100 + j * 10 + k;
- if (num % 3 == 0) {
- special += 5;
- } else if (num % 5 == 0) {
- special -= 2;
- } else if (num % 2 == 0) {
- special *= 2;
- }
- if (special >= control) {
- console.log(`Yes! Control number was reached! Current special number is ${special}.`);
- return;
- }
- }
- }
- }
- console.log(`No! ${special} is the last reached special number.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement