0% found this document useful (0 votes)
7 views

Factorial

The document describes a Python program to find the factorial of a number. It provides the aim, algorithm, pseudocode, implementation code and sample outputs of the program.

Uploaded by

jayashree.s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Factorial

The document describes a Python program to find the factorial of a number. It provides the aim, algorithm, pseudocode, implementation code and sample outputs of the program.

Uploaded by

jayashree.s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

GE3171 – Problem Solving and Python Programming Laboratory Page No:

Ex. No: 4.1

Find Factorial of a number


Date:

AIM:

To Develop the Python Program for Find Factorial of a Number.

ALGORITHM:

Step 1: Start Process


Step 2: Define a function using def keyword with an parameter n
Step 3: If n==1 or n==0 return value 1
Step 4: Else return n*factorial (n-1)
Step 5: Read n variable from user input
Step 6: Display factorial by calling function (n)
Step 7: Stop process

PSEUDOCODE:

START
DEF factorial (n)
IF n==1 or n==0 THEN
RETURN 1
ELSE
RETURN n*factorial(n-1)
END IF
READ n
DISPLAY factorial(n)
STOP

IMPLEMENTATION CODE:

def factorial(n):

if n==1 or n==0:

return n

else:

return n*factorial(n-1)

n=int(input("Enter a num"))

Name:K.Suvetha Roll Number:23IT57 Branch: B.Tech


IT
GE3171 – Problem Solving and Python Programming Laboratory Page No:

print(factorial(n))

OUTPUT:

CASE 1:

CASE 2:

CASE 3:

RESULT:

The Python Code for Find Factorial of a Number is Written and Executed Successfully.

Name:K.Suvetha Roll Number:23IT57 Branch: B.Tech


IT

You might also like