Skip to content

Commit e5ae5b1

Browse files
Gonzalo DiazGonzalo Diaz
Gonzalo Diaz
authored and
Gonzalo Diaz
committed
Preliminar problem 0060
1 parent 1fc35ec commit e5ae5b1

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/problem0060.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { isPrime } from './helpers/index.js';
2+
3+
const top = 5;
4+
const primes = [3];
5+
let currentPrime = 3;
6+
7+
function testPrimeConcat(a, b) {
8+
const test1 = `${a}${b}`;
9+
const test2 = `${b}${a}`;
10+
11+
const tResult1 = isPrime(parseInt(test1, 10));
12+
const tResult2 = isPrime(parseInt(test2, 10));
13+
14+
console.log(
15+
`${test1}? is Prime? ${tResult1} | ${test2}? is Prime? ${tResult2}`
16+
);
17+
18+
return tResult1 && tResult2;
19+
}
20+
21+
do {
22+
let found;
23+
let i = currentPrime;
24+
25+
if (isPrime(i)) {
26+
do {
27+
found = testPrimeConcat(i, currentPrime);
28+
29+
if (found) {
30+
currentPrime = i;
31+
primes.push(i);
32+
}
33+
} while (!found);
34+
}
35+
36+
i += 1;
37+
} while (primes.length < top);

src/problem0060.test.js

Whitespace-only changes.

0 commit comments

Comments
 (0)