Write a pseudo-code to calculate the factorial of a given number.
Example: factorial of 5 = 5*4*3*2*1 = 120.
Note 1: Factorial of 0 is 1.
Appeared in InfyTQ.
Kindly answer.
Attachments:
Answers
Answered by
17
Answer:
step 1:
declare number and factorial as integer variable.
step 2:
initialize Factorial=1
step 3:
enter value of Number
step 4:
check whether number=0, if not then number=1
step 5:
if yes then, factorial= factorial*number
step 6:
repeat step 4 and 5 until number=0
step 7:
print value of factorial
step 8:
stop
Answered by
63
Answer:
Factorial=1
input Number
if(Number==0) then
Factorial=1
else
while(Number!=0) do
Factorial=Factorial*Number
Number=Number-1
end-while
end-if
display Factorial
Similar questions
Math,
6 months ago
Chemistry,
1 year ago
Computer Science,
1 year ago
Math,
1 year ago
Science,
1 year ago