Так как язык не указан, приведу пример на SWI-Prolog.
Код:
read_int(Int) :- read(Int), integer(Int).split_int_by_numbers(0, []) :- !.split_int_by_numbers(N, [Number|Ints]) :- Number is mod(N, 10), RestN is div(N, 10), split_int_by_numbers(RestN, Ints).test_to_div(_, []).test_to_div(N, [Number|Ints]) :- mod(N, Number) =:= 0, test_to_div(N, Ints). test(Int) :- split_int_by_numbers(Int, Numbers), test_to_div(Int, Numbers), write(Int), write(" - Yes!"), nl.test(Int) :- write(Int), write(" - No!"), nl.?- read_int(Int), test(Int).
x:real;
begin
x:=0;
while x<=2.0001 do begin
Writeln('x=',x:5:2,' y=',sqr(x)+1:0:4);
x:=x+0.25
end
end.
Результат выполнения программы:
x= 0.00 y=1.0000
x= 0.25 y=1.0625
x= 0.50 y=1.2500
x= 0.75 y=1.5625
x= 1.00 y=2.0000
x= 1.25 y=2.5625
x= 1.50 y=3.2500
x= 1.75 y=4.0625
x= 2.00 y=5.0000