pseudocode for factorial in python
Answers
ɢᴏᴏᴅ ᴍᴏʀɴɪɴɢ!
ᴍᴀʀᴋ ᴍʏ ᴀɴsᴡᴇʀ ᴀs ʙʀᴀɪɴʟɪᴇsᴛ ғᴏʟʟᴏᴡ ᴍᴇ
Pseudocode for Factorial of a number :
Step 1: Declare N and F as integer variable.
Step 2: Initialize F=1.
Step 2: Enter the value of N.
Step 3: Check whether N>0, if not then F=1.
Step 4: If yes then, F=F*N.
Step 5: Decrease the value of N by 1 .
Step 6: Repeat step 4 and 5 until N=0.
Step 7: Now print the value of F.
The value of F will be the factorial of N(number).
Answer:
take care of yourself and achieve success in life
mark me as brainlest and follow me
Explanation:
In this program we have defined a function factorial(). This function takes a number as an argument and finds the factorial of it.
# This Python Program finds the factorial of a number def factorial(num): """This is a recursive function that calls itself to find the factorial of given number""" if num == 1: return num else: return num * factorial(num - 1) # We will find the factorial of this number num = int(input("Enter a Number: ")) # if input number is negative then return an error message # elif the input number is 0 then display 1 as output # else calculate the factorial by calling the user defined function if num < 0: print("Factorial cannot be found for negative numbers") elif num == 0: print("Factorial of 0 is 1") else: print("Factorial of", num, "is: ", factoria