Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function primePairs(input) {
- let firstStart = Number(input[0]);
- let secondStart = Number(input[1]);
- let firstDiff = Number(input[2]);
- let secondDiff = Number(input[3]);
- for (let i = firstStart; i <= firstStart + firstDiff; i++) {
- for (let j = secondStart; j <= secondStart + secondDiff; j++) {
- let isFirstPrime = true;
- let isSecondPrime = true;
- for (let k = 2; k <= Math.sqrt(i); k++) {
- if (i % k === 0) {
- isFirstPrime = false;
- break;
- }
- }
- for (let k = 2; k <= Math.sqrt(j); k++) {
- if (j % k === 0) {
- isSecondPrime = false;
- break;
- }
- }
- if (isFirstPrime && isSecondPrime) {
- console.log(`${i}${j}`);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement