Write a program in Pascal Write a program to calculate the sum of factorials of odd numbers

Write a program in Pascal Write a program to calculate the sum of factorials of odd numbers from 1 to 9. To calculate the factorial use the procedure

It is very important to make sure that the compiler treats longint as a 32-bit integer. This can be checked in the settings.

program CalculatingFactorialWithFucntions;

{Function to count factorials}
function factorial (x: integer): integer;
Begin
if (x = 1) then
Begin
factorial: = 1;
end
else
factorial: = x * factorial (x – 1)
end;

{Procedure for starting this function}
procedure calculate;
var i: integer;
sum: longint;
Begin
sum: = 0;
Writeln (‘I am counting the sum of factorials of odd numbers from 1 to 9.’);
for i: = 1 to 9
do
begin
if (i mod 2 = 1) then begin sum: = sum + factorial (i);
end;
end;
Writeln (sum);
end;
Begin
calculate;
end.



One of the components of a person's success in our time is receiving modern high-quality education, mastering the knowledge, skills and abilities necessary for life in society. A person today needs to study almost all his life, mastering everything new and new, acquiring the necessary professional qualities.