Так как язык не указан, приведу пример на SWI-Prolog.
Код:
begin
writeln('1: ',(sqrt(10)+1)/(6.25-1.8*1.8));
writeln('2: ',sin(5)/cos(5)*10*sqrt(19));
writeln('3: ',100*sin(4));
writeln('4: ',sin(cos(1))/0.25);
writeln('5: ',exp(sin(3))*ln(2));
writeln('6: ',sqrt(sqrt(5)+sqrt(6)));
writeln('7: ',(sqrt(3)+2*sqrt(2))/sqrt(sqrt(5)));
writeln('8: ',(exp(sin(3))*ln(2)+exp(sin(2))*ln(2))/(exp(2.4)*ln(4)+1));
end.
Результат:
1: 1.38281649839481
2: -147.353232893516
3: -75.6802495307928
4: 2.0575810340942
5: 0.798202533367663
6: 2.16461491269994
7: 3.04977540329462
8: 0.0980510445730408
Подробнее - на -
Объяснение:
Так как язык не указан, приведу пример на 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).begin
writeln('1: ',(sqrt(10)+1)/(6.25-1.8*1.8));
writeln('2: ',sin(5)/cos(5)*10*sqrt(19));
writeln('3: ',100*sin(4));
writeln('4: ',sin(cos(1))/0.25);
writeln('5: ',exp(sin(3))*ln(2));
writeln('6: ',sqrt(sqrt(5)+sqrt(6)));
writeln('7: ',(sqrt(3)+2*sqrt(2))/sqrt(sqrt(5)));
writeln('8: ',(exp(sin(3))*ln(2)+exp(sin(2))*ln(2))/(exp(2.4)*ln(4)+1));
end.
Результат:
1: 1.38281649839481
2: -147.353232893516
3: -75.6802495307928
4: 2.0575810340942
5: 0.798202533367663
6: 2.16461491269994
7: 3.04977540329462
8: 0.0980510445730408
Подробнее - на -
Объяснение: