Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let n = input[0];
- let nLast = Number(n[n.length - 1]);
- let a = 1;
- let b = 9;
- let c = 0;
- let d = 9;
- let sum = 0;
- let multiply = 0;
- let division = 0;
- let counter = 0;
- label:
- for (let a = 1; a <= 9; a++) {
- for (let b = 9; b >= a; b--) {
- for (let c = 1; c <= 9; c++) {
- for (let d = 8; d >= c; d--) {
- sum = a + b + c + d;
- multiply = a * b * c * d;
- division = Math.floor(multiply / 19);
- if (sum === multiply && nLast === 5) {
- console.log(`${a}${b}${c}${d}`);
- counter += 1;
- break label;
- } else if (division === 3 && Number(n) % 3 === 0) {
- console.log(`${d}${c}${b}${a}`);
- counter += 1;
- break label;
- }
- }
- }
- }
- }
- if (counter === 0) {
- console.log(`Nothing found`);
- }
- }
- solve([
- // '123'
- '145'
- ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement