
Так как язык не указан, приведу пример на 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).

xD
uses crt;
var
dt,t1,t2:LongInt;
function GetTime:LongInt;
var
substr,str:string;
ERR,step,spacepos,code,num:Integer;
t:longint;
begin
ERR:=0;
repeat
t:=0;
step:=1;
if ERR<>0 then writeln('Nepravilnie dannie, povtorite vvod:');
ERR:=0;
readln(str);
str:=str+' ';
repeat
spacepos:=pos(' ',str);
if (spacepos<>0) then
begin
substr:=copy(str,1,spacepos-1);
delete(str,1,spacepos);
val(substr,num,code);
if code=0 then
begin
if (step=1) then begin if (num>=0) and (num<=23) then t:=t+num*60*60 else ERR:=3; end;
if (step=2) then begin if (num>=0) and (num<=59) then t:=t+num*60 else ERR:=3;end;
if (step=3) then begin if (num>=0) and (num<=59) then t:=t+num else ERR:=3;end;
inc(step);
end
else ERR:=2;
end else ERR:=1;
until ((step=4) or (err<>0));
until err=0;
GetTime:=t;
end;
begin
writeln('pervoe vremy:');
t1:=GetTime;
writeln('vtoroe vremy:');
t2:=GetTime;
if t2>=t1 then dt:=t2-t1 else dt:=t2-t1+24*60*60;
writeln('raznica v sekundah: ');
writeln(dt);
end.