# Write a program in Pascal Find all natural numbers not exceeding a given n that are divisible by each of their digits.

July 23, 2021 | education

| program divide_;

var i, f, k, n, m: integer;

begin

writeln (‘Enter a number’);

readln (n); // n – limit number

for i: = 1 to n do

begin

f: = 1;

m: = i; // copy of the next number

while m <> 0 do

begin

k: = m mod 10;

if (k = 0) or (i mod k> 0) then f: = 0;

// If the next digit is zero

// or if the number is not divisible by the digit of the number, then the flag f = 0

m: = m div 10;

end;

if f = 1 then writeln (i);

end

end.

One of the components of a person's success in our time is receiving modern high-quality education, mastering the knowledge, skills and abilities necessary for life in society. A person today needs to study almost all his life, mastering everything new and new, acquiring the necessary professional qualities.