function Cube(num: integer): integer; begin Cube := num num num; end;
function SumOfCubes(num: integer): integer; begin SumOfCubes := 0; while num > 0 do begin digit := num mod 10; SumOfCubes := SumOfCubes + Cube(digit); num := num div 10; end; end;
begin write('Enter the value of n: '); readln(n);
writeln('The first ', n, ' numbers equal to the sum of the cubes of their digits are:');
num := 1; count := 0;
while count < n do begin sum := SumOfCubes(num); if num = sum then begin writeln(num); count := count + 1; end; num := num + 1; end;
program SearchNumbers;
var
n, num, digit, sum, i, count: integer;
function Cube(num: integer): integer;
begin
Cube := num num num;
end;
function SumOfCubes(num: integer): integer;
begin
SumOfCubes := 0;
while num > 0 do
begin
digit := num mod 10;
SumOfCubes := SumOfCubes + Cube(digit);
num := num div 10;
end;
end;
begin
write('Enter the value of n: ');
readln(n);
writeln('The first ', n, ' numbers equal to the sum of the cubes of their digits are:');
num := 1;
count := 0;
while count < n do
begin
sum := SumOfCubes(num);
if num = sum then
begin
writeln(num);
count := count + 1;
end;
num := num + 1;
end;
readln;
end.