Minimum multiple of m where digital sum equals m
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
ALGOL 68
<lang algol68>BEGIN # find the smallest m where mn = digit sum of n, n in 1 .. 70 #
# returns the digit sum of n, n must be >= 0 # OP DIGITSUM = ( INT n )INT: IF n < 10 THEN n ELSE INT result := n MOD 10; INT v := n OVER 10; WHILE v > 0 DO result +:= v MOD 10; v := v OVER 10 OD; result FI # DIGITSUM # ; # show the minimum multiples of n where the digit sum of the multiple is n # FOR n TO 70 DO BOOL found multiple := FALSE; FOR m WHILE NOT found multiple DO IF DIGITSUM ( m * n ) = n THEN found multiple := TRUE; print( ( " ", whole( m, -8 ) ) ); IF n MOD 10 = 0 THEN print( ( newline ) ) FI FI OD OD
END</lang>
- Output:
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
APL
<lang APL>{n←⍵ ⋄ (+∘1)⍣{n=+/10⊥⍣¯1⊢⍺×n}⊢0 } ¨ 7 10⍴⍳70</lang>
- Output:
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
BASIC
BASIC256
<lang BASIC256>c = 0 n = 1 while c < 70
m = 1 while 1 nm = n*m
t = 0
while nm t += nm mod 10 nm = floor(nm / 10) end while if t = n then exit while m += 1 end while c += 1 print rjust(string(m), 8); " "; if c mod 10 = 0 then print n += 1
end while end</lang>
- Output:
Igual que la entrada de FreeBASIC.
FreeBASIC
<lang freebasic>#define floor(x) ((x*2.0-0.5) Shr 1)
Dim As Integer c = 0, n = 1 Do While c < 70
Dim As Integer m = 1 Do Dim As Integer nm = n*m, t = 0 While nm t += nm Mod 10 nm = floor(nm/10) Wend If t = n Then Exit Do : End If m += 1 Loop c += 1 Print Using "######## "; m; If c Mod 10 = 0 Then Print n += 1
Loop Sleep </lang>
- Output:
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
Yabasic
<lang yabasic>c = 0 n = 1 while c < 70
m = 1 do nm = n*m
t = 0
while nm t = t + mod(nm, 10) nm = floor(nm / 10) wend if t = n then break : fi m = m + 1 loop c = c + 1 print m using "########", " "; if mod(c, 10) = 0 then print : fi n = n + 1
wend end</lang>
- Output:
Igual que la entrada de FreeBASIC.
C
<lang c>#include <stdio.h>
unsigned digit_sum(unsigned n) {
unsigned sum = 0; do { sum += n % 10; } while(n /= 10); return sum;
}
unsigned a131382(unsigned n) {
unsigned m; for (m = 1; n != digit_sum(m*n); m++); return m;
}
int main() {
unsigned n; for (n = 1; n <= 70; n++) { printf("%9u", a131382(n)); if (n % 10 == 0) printf("\n"); } return 0;
}</lang>
- Output:
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
C++
<lang cpp>#include <iomanip>
- include <iostream>
int digit_sum(int n) {
int sum = 0; for (; n > 0; n /= 10) sum += n % 10; return sum;
}
int main() {
for (int n = 1; n <= 70; ++n) { for (int m = 1;; ++m) { if (digit_sum(m * n) == n) { std::cout << std::setw(8) << m << (n % 10 == 0 ? '\n' : ' '); break; } } }
}</lang>
- Output:
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
CLU
<lang clu>digit_sum = proc (n: int) returns (int)
sum: int := 0 while n > 0 do sum := sum + n // 10 n := n / 10 end return(sum)
end digit_sum
a131382 = iter () yields (int)
n: int := 1 while true do m: int := 1 while digit_sum(m * n) ~= n do m := m + 1 end yield(m) n := n + 1 end
end a131382
start_up = proc ()
po: stream := stream$primary_output() n: int := 0 for m: int in a131382() do stream$putright(po, int$unparse(m), 9) n := n + 1 if n = 70 then break end if n // 10 = 0 then stream$putl(po, "") end end
end start_up</lang>
- Output:
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
COBOL
<lang cobol> IDENTIFICATION DIVISION.
PROGRAM-ID. A131382. DATA DIVISION. WORKING-STORAGE SECTION. 01 VARIABLES. 03 MAXIMUM PIC 99 VALUE 40. 03 N PIC 999. 03 M PIC 9(9). 03 N-TIMES-M PIC 9(9). 03 DIGITS PIC 9 OCCURS 9 TIMES, REDEFINES N-TIMES-M, INDEXED BY D. 03 DIGITSUM PIC 999 VALUE ZERO. 01 OUTFMT. 03 FILLER PIC XX VALUE "A(". 03 N-OUT PIC Z9. 03 FILLER PIC X(4) VALUE ") = ". 03 M-OUT PIC Z(8)9. PROCEDURE DIVISION. BEGIN. PERFORM CALC-A131382 VARYING N FROM 1 BY 1 UNTIL N IS GREATER THAN MAXIMUM. STOP RUN. CALC-A131382. PERFORM FIND-LEAST-M VARYING M FROM 1 BY 1 UNTIL DIGITSUM IS EQUAL TO N. SUBTRACT 1 FROM M. MOVE N TO N-OUT. MOVE M TO M-OUT. DISPLAY OUTFMT. FIND-LEAST-M. MOVE ZERO TO DIGITSUM. MULTIPLY N BY M GIVING N-TIMES-M. PERFORM ADD-DIGIT VARYING D FROM 1 BY 1 UNTIL D IS GREATER THAN 9. ADD-DIGIT. ADD DIGITS(D) TO DIGITSUM.</lang>
- Output:
A( 1) = 1 A( 2) = 1 A( 3) = 1 A( 4) = 1 A( 5) = 1 A( 6) = 1 A( 7) = 1 A( 8) = 1 A( 9) = 1 A(10) = 19 A(11) = 19 A(12) = 4 A(13) = 19 A(14) = 19 A(15) = 13 A(16) = 28 A(17) = 28 A(18) = 11 A(19) = 46 A(20) = 199 A(21) = 19 A(22) = 109 A(23) = 73 A(24) = 37 A(25) = 199 A(26) = 73 A(27) = 37 A(28) = 271 A(29) = 172 A(30) = 1333 A(31) = 289 A(32) = 559 A(33) = 1303 A(34) = 847 A(35) = 1657 A(36) = 833 A(37) = 1027 A(38) = 1576 A(39) = 1282 A(40) = 17497
Cowgol
<lang cowgol>include "cowgol.coh";
sub digit_sum(n: uint32): (sum: uint8) is
sum := 0; while n != 0 loop sum := sum + (n % 10) as uint8; n := n / 10; end loop;
end sub;
sub a131382(n: uint8): (m: uint32) is
m := 1; while n != digit_sum(n as uint32 * m) loop m := m + 1; end loop;
end sub;
var n: uint8 := 1; while n <= 70 loop
print_i32(a131382(n)); if n % 10 == 0 then print_nl(); else print_char(' '); end if; n := n + 1;
end loop;</lang>
- Output:
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
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>
- Output:
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
Forth
<lang forth>: digit-sum ( u -- u )
dup 10 < if exit then 10 /mod recurse + ;
- main
1+ 1 do 0 begin 1+ dup i * digit-sum i = until 8 .r i 10 mod 0= if cr else space then loop ;
70 main bye</lang>
- Output:
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
Haskell
<lang haskell>import Data.Bifunctor (first) import Data.List (elemIndex, intercalate, transpose) import Data.List.Split (chunksOf) import Data.Maybe (fromJust) import Text.Printf (printf)
A131382 ------------------------
a131382 :: [Int] a131382 =
fromJust . (elemIndex <*> productDigitSums) <$> [1 ..]
productDigitSums :: Int -> [Int] productDigitSums n = digitSum . (n *) <$> [0 ..]
TEST -------------------------
main :: IO () main =
(putStrLn . table " ") $ chunksOf 10 $ show <$> take 40 a131382
GENERIC ------------------------
digitSum :: Int -> Int digitSum 0 = 0 digitSum n = uncurry (+) (first digitSum $ quotRem n 10)
table :: String -> String -> String table gap rows =
let ws = maximum . fmap length <$> transpose rows pw = printf . flip intercalate ["%", "s"] . show in unlines $ intercalate gap . zipWith pw ws <$> rows</lang>
- Output:
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
J
Implementation:
<lang J> findfirst=: Template:($:@((+1+i.@+:)@
A131382=: {{y&Template:X = sumdigits x*y findfirst}}"0
sumdigits=: +/@|:@(10&#.inv)</lang>
Task example: <lang J> A131382 1+i.4 10
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</lang>
Stretch example: <lang J> A131382 41+i.3 10
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</lang>
Julia
<lang julia>minproddigsum(n) = findfirst(i -> sum(digits(n * i)) == n, 1:typemax(Int32))
for j in 1:70
print(lpad(minproddigsum(j), 10), j % 7 == 0 ? "\n" : "")
end
</lang>
- Output:
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
MAD
<lang MAD> NORMAL MODE IS INTEGER
VECTOR VALUES FMT = $2HA(,I2,4H) = ,I8*$ THROUGH NUMBER, FOR N = 1, 1, N.G.70
MULT THROUGH MULT, FOR M = 1, 1, N.E.DSUM.(M*N) NUMBER PRINT FORMAT FMT, N, M
INTERNAL FUNCTION(X) ENTRY TO DSUM. SUM = 0 V = X
DIGIT WHENEVER V.E.0, FUNCTION RETURN SUM
W = V/10 SUM = SUM + V - W*10 V = W TRANSFER TO DIGIT END OF FUNCTION END OF PROGRAM</lang>
- Output:
A( 1) = 1 A( 2) = 1 A( 3) = 1 A( 4) = 1 A( 5) = 1 A( 6) = 1 A( 7) = 1 A( 8) = 1 A( 9) = 1 A(10) = 19 A(11) = 19 A(12) = 4 A(13) = 19 A(14) = 19 A(15) = 13 A(16) = 28 A(17) = 28 A(18) = 11 A(19) = 46 A(20) = 199 A(21) = 19 A(22) = 109 A(23) = 73 A(24) = 37 A(25) = 199 A(26) = 73 A(27) = 37 A(28) = 271 A(29) = 172 A(30) = 1333 A(31) = 289 A(32) = 559 A(33) = 1303 A(34) = 847 A(35) = 1657 A(36) = 833 A(37) = 1027 A(38) = 1576 A(39) = 1282 A(40) = 17497 A(41) = 4339 A(42) = 2119 A(43) = 2323 A(44) = 10909 A(45) = 11111 A(46) = 12826 A(47) = 14617 A(48) = 14581 A(49) = 16102 A(50) = 199999 A(51) = 17449 A(52) = 38269 A(53) = 56413 A(54) = 37037 A(55) = 1108909 A(56) = 142498 A(57) = 103507 A(58) = 154981 A(59) = 150661 A(60) = 1333333 A(61) = 163918 A(62) = 322579 A(63) = 315873 A(64) = 937342 A(65) = 1076923 A(66) = 1030303 A(67) = 880597 A(68) = 1469116 A(69) = 1157971 A(70) = 12842857
Pascal
Free Pascal
Constructing minimal start number with sum of digits = m -> k+9+9+9+9+9+9
Up to 100 at home.
<lang pascal>
program m_by_n_sumofdgts_m;
//Like https://oeis.org/A131382/b131382.txt
{$IFDEF FPC} {$MODE DELPHI} {$OPTIMIZATION ON,ALL} {$ENDIF}
const
BASE = 10; BASE4 = BASE*BASE*BASE*BASE;
var
SoD: array[0..BASE4-1] of byte;
procedure Init_SoD; var
d0,d1,i,j : NativeInt;
begin
i := 0; For d1 := 0 to BASE-1 do For d0 := 0 to BASE-1 do begin SoD[i]:= d1+d0;inc(i); end;
j := Base*Base; For i := 1 to Base*Base-1 do For d1 := 0 to BASE-1 do For d0 := 0 to BASE-1 do begin SoD[j] := SoD[i]+d1+d0; inc(j); end;
end;
function SumOfDigits(n:nativeUint):NativeUint; var
q : NativeUint;
begin
result := 0; while n>0 do begin q := n DIV BASE4; result += SoD[n-BASE4*q]; n := q; end;
end;
var
i : NativeInt; m,n: NativeUint;
Begin
Init_SoD; for m := 1 to 90 do begin n := m; //constructing minimal number with sum of digits = m ;k+9+9+9+9+9+9 //21 -> 299 if n>BASE then begin i := 1; while n>BASE-1 do begin i *= BASE; dec(n,BASE-1); end; n := i*(n+1)-1; //make n multiple of m n := (n div m)*m; //m ending in 0 i := m; while i mod BASE = 0 do begin n *= BASE; i := i div BASE; end; end; while SumOfDigits(n)<> m do inc(n,m); write(n DIV m:11); if m mod 10 = 0 then writeln; end;
end. </lang>
- @TIO.RUN:
Real time: 4.161 s CPU share: 99.35 % 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 4084507 5555554 6849163 37027027 13333333 11710513 11686987 11525641 12656962 374999986 12345679 60852439 72168553 82142857 117647047 93022093 103445977 227272726 112247191 1111111111 @home: ..100 ... 12345679 60852439 72168553 82142857 117647047 93022093 103445977 227272726 112247191 1111111111 658010989 652173913 731172043 849893617 2947368421 2083333228 1030927834 3969377551 11101010101 199999999999 real 1m15,075 // 99 takes the longest time.
Perl
<lang perl>#!/usr/bin/perl
use strict; # https://rosettacode.org/wiki/Minimum_multiple_of_m_where_digital_sum_equals_m use warnings; use ntheory qw( sumdigits );
my @answers = map
{ my $m = 1; $m++ until sumdigits($m*$_) == $_; $m; } 1 .. 70;
print "@answers\n\n" =~ s/.{65}\K /\n/gr;</lang>
- Output:
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
Phix
with javascript_semantics integer c = 0, n = 1 while c<70 do integer m = 1 while true do integer nm = n*m, t = 0 while nm do t += remainder(nm,10) nm = floor(nm/10) end while if t=n then exit end if m += 1 end while c += 1 printf(1,"%-8d%s",{m,iff(remainder(c,10)=0?"\n":"")}) n += 1 end while
- Output:
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
Python
<lang python>A131382
from itertools import count, islice
- a131382 :: [Int]
def a131382():
An infinite series of the terms of A131382 return ( elemIndex(x)( productDigitSums(x) ) for x in count(1) )
- productDigitSums :: Int -> [Int]
def productDigitSums(n):
The sum of the decimal digits of n return (digitSum(n * x) for x in count(0))
- ------------------------- TEST -------------------------
- main :: IO ()
def main():
First 40 terms of A131382
print( table(10)([ str(x) for x in islice( a131382(), 40 ) ]) )
- ----------------------- GENERIC ------------------------
- chunksOf :: Int -> [a] -> a
def chunksOf(n):
A series of lists of length n, subdividing the contents of xs. Where the length of xs is not evenly divisible, the final list will be shorter than n. def go(xs): return ( xs[i:n + i] for i in range(0, len(xs), n) ) if 0 < n else None return go
- digitSum :: Int -> Int
def digitSum(n):
The sum of the digital digits of n. return sum(int(x) for x in list(str(n)))
- elemIndex :: a -> [a] -> (None | Int)
def elemIndex(x):
Just the first index of x in xs, or None if no elements match. def go(xs): try: return next( i for i, v in enumerate(xs) if x == v ) except StopIteration: return None return go
- table :: Int -> [String] -> String
def table(n):
A list of strings formatted as right-justified rows of n columns. def go(xs): w = len(xs[-1]) return '\n'.join( ' '.join(row) for row in chunksOf(n)([ s.rjust(w, ' ') for s in xs ]) ) return go
- MAIN ---
if __name__ == '__main__':
main()</lang>
- Output:
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
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
Wren
<lang ecmascript>import "./math" for Int import "./seq" for Lst import "./fmt" for Fmt
var res = [] for (n in 1..70) {
var m = 1 while (Int.digitSum(m * n) != n) m = m + 1 res.add(m)
} for (chunk in Lst.chunks(res, 10)) Fmt.print("$,10d", chunk)</lang>
- Output:
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 1,333 289 559 1,303 847 1,657 833 1,027 1,576 1,282 17,497 4,339 2,119 2,323 10,909 11,111 12,826 14,617 14,581 16,102 199,999 17,449 38,269 56,413 37,037 1,108,909 142,498 103,507 154,981 150,661 1,333,333 163,918 322,579 315,873 937,342 1,076,923 1,030,303 880,597 1,469,116 1,157,971 12,842,857
XPL0
<lang XPL0>func SumDigits(N); \Return sum of digits in N int N, S; [S:= 0; while N do
[N:= N/10; S:= S + rem(0); ];
return S; ];
int C, N, M; [C:= 0; N:= 1; repeat M:= 1;
while SumDigits(N*M) # N do M:= M+1; IntOut(0, M); C:= C+1; if rem (C/10) then ChOut(0, 9\tab\) else CrLf(0); N:= N+1;
until C >= 40+30; ]</lang>
- Output:
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