A Harshad Number in a given number base is an integer that is divisible by the sum of its digits when written in that base.
For example, the number 11 in base 5 (which is 6 in base 10) is divisible by 1 + 1 = 2 in base 5. It is therefore a Harshad number in base 5.
1 is the first Harshad number in base 5. Let H be the 1000th Harshad Number in base 5. What are the first 3 digits of H?
Details and assumptions
Remember: H is in base 5!
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Java code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
Now, when the program runs, the line
1000 4270
is printed. Converting
4
2
7
0
to base
5
, we get
4
2
7
0
=
1
1
4
2
0
5
=
>
1
1
4
The 1 0 0 0 t h Harshad number in base 5 is 1 1 4 0 4 0 . I used the following Python coding. Please note that the digital sum in base 5 is same as that in base 1 0 .
x = 0
n = -1
for a in range (2):
for b in range (5):
for c in range (5):
for d in range(5):
for e in range(5):
for f in range(5):
n += 1
h = str(a)+str(b)+str(c)+str(d)+str(e)+str(f)
s = 0
for i in range(len(h)):
s += int(h[i])
if n > 0 and n % s == 0:
x += 1
print x, h, n, s
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
Problem Loading...
Note Loading...
Set Loading...
The 1000th Harshad number is 114040 (this is in base 5 representation). The first three digits are 114 .
One solution is to iterate through the base 10 numbers, and check if they are base 5 Harshad numbers. Continue until you find the 1000th base 5 Harshad. Make sure to give your answer in base 5 representation.
To check if a base 10 number N is a Harshad in base 5, first convert N to base 5. Let F be the base 5 representation of N . Second, add up the digits of F and represent the sum S in base 10. Finally, if N modulo S is 0, then they are divisible and F is a Harshad number in base 5.