Think of this problem as an extension of
Two Digit Integers.
Find all possible three digit positive integers N for which the sum of digits of 10N - N is divisible by 170.
Provide valid reasons for your answer.
Note: Computer program/ spreadsheet aided methodologies are welcome, but a semi-analytic (simple calculator + p&p) solution is preferred.
There are no 3-digit integers which satisfy the required conditions.
The 2-digit solutions (from the earlier problem) are:
20
39
58
77
96
The 4-digit solutions are:
1512
1531
1607
1626
1645
1664
1683
1740
1759
1778
1797
3004
3023
3042
3061
3118
3137
3156
3175
3194
3270
3289
4705
4724
4743
4762
4781
4819
4838
4857
4876
4895
4990
6102
6121
6216
6235
6254
6273
6292
6330
6349
6368
6387
7803
7822
7841
7917
7936
7955
7974
7993
9314
9333
9352
9371
9409
9428
9447
9466
9485
9580
9599
I made 2 versions of code to solve this and I checked all values less than 5 digits. On my system the reported times were 12.828125 and 0.015625, so the second version ran 873 times faster.
The less efficient algorithm simply calculated the expression 10^n - n.
The more efficient algorithm figured the number of leading 9's and then the final few digits.
-------------
ans1 = []
ans2 = []
big = 10000
# Version One:
for n in (range(big)):
if sod(10**n - n)%170 == 0:
ans1.append(n)
# Version Two:
for n in range(big):
lenn = len(str(n))
last_n_digits = 10**lenn - n
num_9s = n - lenn
mysod = 9*num_9s + sod(last_n_digits)
if mysod%170 == 0:
ans2.append(n)
|
Posted by Larry
on 2023-04-19 11:07:43 |