Minimum multiple of m where digital sum equals m: Difference between revisions

From Rosetta Code
Content added Content deleted
m (fix link)
m (clarify slightly)
Line 1: Line 1:
{{draft task}}
{{draft task}}


Generate the sequence '''a(n)''' when each '''n''' is the minimum integer multiple '''m''' such that the digit sum of '''n''' times '''m''' is equal to '''n'''.
Generate the sequence '''a(n)''' when each element is the minimum integer multiple '''m''' such that the digit sum of '''n''' times '''m''' is equal to '''n'''.





Revision as of 14:58, 22 January 2022

Minimum multiple of m where digital sum equals m is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Generate the sequence a(n) when each element is the minimum integer multiple m such that the digit sum of n times m is equal to n.


Task
  • Find the first 40 elements of the sequence.


Stretch
  • Find the next 30 elements of the sequence.


See also



Raku

<lang perl6>sub min-mult-dsum ($n) { (1..∞).first: (* × $n).comb.sum == $n }

say .fmt("%2d: ") ~ .&min-mult-dsum for flat 1..40, 41..70;</lang>

Output:
 1: 1
 2: 1
 3: 1
 4: 1
 5: 1
 6: 1
 7: 1
 8: 1
 9: 1
10: 19
11: 19
12: 4
13: 19
14: 19
15: 13
16: 28
17: 28
18: 11
19: 46
20: 199
21: 19
22: 109
23: 73
24: 37
25: 199
26: 73
27: 37
28: 271
29: 172
30: 1333
31: 289
32: 559
33: 1303
34: 847
35: 1657
36: 833
37: 1027
38: 1576
39: 1282
40: 17497
41: 4339
42: 2119
43: 2323
44: 10909
45: 11111
46: 12826
47: 14617
48: 14581
49: 16102
50: 199999
51: 17449
52: 38269
53: 56413
54: 37037
55: 1108909
56: 142498
57: 103507
58: 154981
59: 150661
60: 1333333
61: 163918
62: 322579
63: 315873
64: 937342
65: 1076923
66: 1030303
67: 880597
68: 1469116
69: 1157971
70: 12842857