How to resolve the algorithm Minimum multiple of m where digital sum equals m step by step in the SETL programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Minimum multiple of m where digital sum equals m step by step in the SETL programming language

Table of Contents

Problem Statement

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.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Minimum multiple of m where digital sum equals m step by step in the SETL programming language

Source code in the setl programming language

program minimum_multiple_of_m_where_digit_sum_equals_m;
    loop for n in [1..70] do
        putchar(lpad(str minmult n, 9));
        if n mod 10=0 then print; end if;
    end loop;

    op minmult(m);
        n := 1;
        (while digsum(n*m) /= m) n +:= 1; end;
        return n;
    end op;

    op digsum(n);
        return +/[[n mod 10, n div:=10](1) : until n=0];
    end op;
end program;

  

You may also check:How to resolve the algorithm Copy a string step by step in the ooRexx programming language
You may also check:How to resolve the algorithm Water collected between towers step by step in the Ada programming language
You may also check:How to resolve the algorithm Pi step by step in the PL/I programming language
You may also check:How to resolve the algorithm Long multiplication step by step in the PL/M programming language
You may also check:How to resolve the algorithm FizzBuzz step by step in the Applesoft BASIC programming language