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

Add Draco
(→‎{{header|Perl}}: prepend Pascal. Like https://oeis.org/A131382/b131382.txt)
(Add Draco)
Line 266:
17449 38269 56413 37037 1108909 142498 103507 154981 150661 1333333
163918 322579 315873 937342 1076923 1030303 880597 1469116 1157971 12842857</pre>
 
=={{header|Draco}}==
<lang draco>/* this is very slow even in emulation - if you're going to try it
* on a real 8-bit micro I'd recommend setting this back to 40;
* it does, however, eventually get there */
byte MAX = 70;
 
/* note on types: 2^32 is a 10-digit number,
* so the digit sum of an ulong is guaranteed
* to be <= 90 */
proc nonrec digitsum(ulong n) byte:
byte sum;
sum := 0;
while n /= 0 do
sum := sum + make(n % 10, byte);
n := n / 10
od;
sum
corp
 
proc nonrec a131382(ulong n) ulong:
ulong m;
m := 1;
while digitsum(m * n) /= n do
m := m + 1
od;
m
corp
 
proc nonrec main() void:
byte n;
for n from 1 upto MAX do
write(a131382(n):9);
if (n & 7) = 0 then writeln() fi
od
corp</lang>
{{out}}
<pre> 1 1 1 1 1 1 1 1
1 19 19 4 19 19 13 28
28 11 46 199 19 109 73 37
199 73 37 271 172 1333 289 559
1303 847 1657 833 1027 1576 1282 17497
4339 2119 2323 10909 11111 12826 14617 14581
16102 199999 17449 38269 56413 37037 1108909 142498
103507 154981 150661 1333333 163918 322579 315873 937342
1076923 1030303 880597 1469116 1157971 12842857</pre>
 
=={{header|Haskell}}==
2,114

edits