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
 OEIS:A131382 - Minimal number m such that Sum_digits(n*m)=n




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;