2018-09-30 23:01:58 +01:00
---
id: 5900f4f11000cf542c510003
title: 'Problem 387: Harshad Numbers'
2020-11-27 19:02:05 +01:00
challengeType: 5
2019-08-05 09:17:33 -07:00
forumTopicId: 302051
2021-01-13 03:31:00 +01:00
dashedName: problem-387-harshad-numbers
2018-09-30 23:01:58 +01:00
---
2020-11-27 19:02:05 +01:00
# --description--
2018-09-30 23:01:58 +01:00
A Harshad or Niven number is a number that is divisible by the sum of its digits.
2020-11-27 19:02:05 +01:00
2018-09-30 23:01:58 +01:00
201 is a Harshad number because it is divisible by 3 (the sum of its digits.)
2020-11-27 19:02:05 +01:00
2018-09-30 23:01:58 +01:00
When we truncate the last digit from 201, we get 20, which is a Harshad number.
2020-11-27 19:02:05 +01:00
2018-09-30 23:01:58 +01:00
When we truncate the last digit from 20, we get 2, which is also a Harshad number.
2020-11-27 19:02:05 +01:00
2018-10-08 01:01:53 +01:00
Let's call a Harshad number that, while recursively truncating the last digit, always results in a Harshad number a right truncatable Harshad number.
2018-09-30 23:01:58 +01:00
2021-07-30 16:59:29 +02:00
Also:
$\frac{201}{3} = 67$ which is prime.
Let's call a Harshad number that, when divided by the sum of its digits, results in a prime a strong Harshad number.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
Now take the number 2011 which is prime. When we truncate the last digit from it we get 201, a strong Harshad number that is also right truncatable. Let's call such primes strong, right truncatable Harshad primes.
2018-09-30 23:01:58 +01:00
You are given that the sum of the strong, right truncatable Harshad primes less than 10000 is 90619.
2021-07-30 16:59:29 +02:00
Find the sum of the strong, right truncatable Harshad primes less than ${10}^{14}$.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --hints--
2018-09-30 23:01:58 +01:00
2021-07-30 16:59:29 +02:00
`harshadNumbers()` should return `696067597313468` .
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
```js
2021-07-30 16:59:29 +02:00
assert.strictEqual(harshadNumbers(), 696067597313468);
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
# --seed--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
## --seed-contents--
2018-09-30 23:01:58 +01:00
```js
2021-07-30 16:59:29 +02:00
function harshadNumbers() {
2020-09-15 09:57:40 -07:00
2018-09-30 23:01:58 +01:00
return true;
}
2021-07-30 16:59:29 +02:00
harshadNumbers();
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
# --solutions--
2018-09-30 23:01:58 +01:00
```js
// solution required
```