Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(maxFirst, maxSecond, maxThird) {
- const minJ = maxSecond < 2 ? 1 : 2
- for (let i = 1; i <= maxFirst; i++) {
- if (i % 2 !== 0) {
- continue;
- }
- for (let j = minJ; j <= Math.min(7, maxSecond); j++) {
- if (!isPrime(j)) {
- continue;
- }
- for (let k = 1; k <= maxThird; k++) {
- if (k % 2 !== 0) {
- continue;
- }
- console.log(`${i} ${j} ${k}`)
- }
- }
- }
- function isPrime(n) {
- for (let j = 2; j < n; j++) {
- if (n % j === 0) {
- return false
- }
- }
- return true
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement