Showing posts with label factorial in turbo pascal. Show all posts
Showing posts with label factorial in turbo pascal. Show all posts

Friday, August 19, 2016

Factorial in Turbo Pascal

A simple program that I wrote using Turbo Pascal for Windows to accept an integer value from the user and then our program will compute the factorial value of the given number by the user.


Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.






 Sample Program Output



Program Listing

Program Factorial_Program;

Uses WinCrt;


Var

   Fact : Longint;
   n    : Integer;

Function Factorial(n : integer) : longint;
Begin
 If N < 1 then
   Begin
   factorial := 1;
   End
 Else
   Factorial := n * factorial(n-1);
End;

Begin
 Clrscr;
 Write('Factorial Program in Turbo Pascal');
 writeln;
 Writeln;
 Write('Enter a Number : ');
 Readln(n);
 fact := factorial(n);
 writeln;
 Writeln('The factorial of ',n:1,' = ',fact,'.');
 Readln;
End.