Description:
Factorial of a number is nothing but the multiplication of numbers from a given number to 1 Ex: 5! =5*4*3*2*1= 120
Algorithm:
main program
Step 1: start Step 2: read n
Step 3: call the sub program fact(n) Step 4: print the f value
Step 5: stop
Sub program:
Step 1: initialize the f=1
Step 2: if n==0 or n=1 return 1 to main program. If not go to step 3
Step 3: perform the looping operation as follows
For i=1 i<=n; i++ Step 4: f=f*i
No comments:
Post a Comment