We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1fc35ec commit e5ae5b1Copy full SHA for e5ae5b1
src/problem0060.js
@@ -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
0 commit comments