audipower

uniquePinCodes

Mar 2nd, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function uniquePinCodes(input) {
  2.  
  3.     let one = Number(input.shift());
  4.     let two = Number(input.shift());
  5.     let three = Number(input.shift());
  6.     let prime = true;
  7.     let result = "";
  8.  
  9.     for (let a = 1; a <= one; a++) {
  10.         for (let b = 1; b <= two; b++) {
  11.             let maxDivider = Math.sqrt(b);
  12.             for (let m = 2; m <= maxDivider; m++) {
  13.                 if (b % m == 0) {
  14.                     prime = false;
  15.                 } else {
  16.                     prime = true;
  17.                 }
  18.             }
  19.             for (let c = 1; c <= three; c++) {
  20.                 if ((a % 2 == 0) && (prime == true && b > 1) && (c % 2 == 0)) {
  21.                     result += `${a} ${b} ${c}\n`;
  22.                 }
  23.             }
  24.         }
  25.     }
  26.     console.log(result);
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment