2018-09-30 23:01:58 +01:00
---
id: 5900f3911000cf542c50fea4
challengeType: 5
title: 'Problem 37: Truncatable primes'
2019-08-05 09:17:33 -07:00
forumTopicId: 302031
2018-09-30 23:01:58 +01:00
---
## Description
<section id='description'>
2020-02-28 21:39:47 +09:00
2018-09-30 23:01:58 +01:00
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3.
2020-02-28 21:39:47 +09:00
Find the sum of the only `n` (8 ≤ `n` ≤ 11) primes that are both truncatable from left to right and right to left.
2018-09-30 23:01:58 +01:00
NOTE: 2, 3, 5, and 7 are not considered to be truncatable primes.
2020-02-28 21:39:47 +09:00
2018-09-30 23:01:58 +01:00
</section>
## Instructions
<section id='instructions'>
</section>
## Tests
<section id='tests'>
```yml
2018-10-04 14:37:37 +01:00
tests:
2020-02-28 21:39:47 +09:00
- text: <code>truncatablePrimes(8)</code> should return a number.
testString: assert(typeof truncatablePrimes(8) === 'number');
2018-10-04 14:37:37 +01:00
- text: <code>truncatablePrimes(8)</code> should return 1986.
2019-07-27 05:34:19 -07:00
testString: assert(truncatablePrimes(8) == 1986);
2018-10-04 14:37:37 +01:00
- text: <code>truncatablePrimes(9)</code> should return 5123.
2019-07-27 05:34:19 -07:00
testString: assert(truncatablePrimes(9) == 5123);
2018-10-04 14:37:37 +01:00
- text: <code>truncatablePrimes(10)</code> should return 8920.
2019-07-27 05:34:19 -07:00
testString: assert(truncatablePrimes(10) == 8920);
2018-10-04 14:37:37 +01:00
- text: <code>truncatablePrimes(11)</code> should return 748317.
2019-07-27 05:34:19 -07:00
testString: assert(truncatablePrimes(11) == 748317);
2018-09-30 23:01:58 +01:00
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function truncatablePrimes(n) {
2020-09-15 09:57:40 -07:00
2018-09-30 23:01:58 +01:00
return n;
}
truncatablePrimes(11);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
2019-07-18 08:24:12 -07:00
2018-09-30 23:01:58 +01:00
</section>