Pascal Program to Find Factorial of a Any Positive Number | Codexpress Programming Blog - Tutorials about, PHP, MySQL and Web Development -->

# Pascal Program to Find Factorial of a Any Positive Number

Hey, is been a while today tutorial is on Pascal Program to Find Factorial of  Any given Positive Number, You will be able to Calculate the factorial of a number using the example i have given below.

I'm sharing this code because it was my examination question on final year of computer Science, Heritage Polytechnic Eket Akwa Ibom State, here in Nigeria.

I have seen this question a lot of time been asked an there is no appropriate answer to it, so i wrote this lines of code in pascal to solve this long time mind troubling question.

You will learn to calculate the factorial of a number using for loop in this example.

Therefore, This example uses nested for loop function in pascal. this pascal program generates factorial.

The factorial of a positive number n is given by:

factorial of n (n!) = 1*2*3*4....n

# Example: Factorial of a Number In Pascal

```program FactorialOfAnyNumber;
var
i,a,b,j:integer; {initialize variables}
begin
writeln('Enter Any number:'); { Display message for next action}
readln(j); {accept input from keyboard}

for i := 1 to j do {loop through value store in j variable}
begin
a:=i*a; {incremnet as it loop an store result in a variable}

for a:=1 to a do { loop result}
begin
b:=a; {store total answer to to variable b}
end; {end for loop statement}
end; {end for loop statement}

writeln('The factorial of ',j,' is = ',b); {Dispay result on screen}