Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
{$N+}
var
x : longint;
y : extended;
temp1, temp2 : longint;
i : longint;
function exponent(number, exp : longint) : longint;
var
count, temp : longint;
begin
temp := 1;
for count := 1 to exp do
temp := temp * number;
exponent := temp;
end;
function factorial(number : longint) : longint;
var
temp : longint;
begin
if number = 1 then
temp := number
else
temp := number * factorial(number - 1);
factorial := temp;
end;
{
begin
for i := 1 to 6 do
writeln(factorial(i));
for i := 1 to 6 do
writeln(exponent(6, i));
end.
}
begin
x := 12;
temp1 := 1 - exponent(x, 2) div factorial(2) + exponent(x, 4) div factorial(4);
temp2 := exponent(x, 6) div factorial(6) + exponent(x, 8) div factorial(8) + exponent(x, 10) div factorial(10);
y := temp1 + temp2;
writeln(y);
end.
You'll need a floating point chip to compile this. Most 486 and Pentium chips will do this.