an algorithm to find the factorial of a number
What is algorithm
- An algorithm is step by step description of the method to solve a problem.
- It is an effective procedure for solving a problem in a finite number of steps an algorithm to find the factorial of a number
How to start writing algorithm : Step by Step solve the problem
- Problem Description – Find description of the problem.
- Problem Analysis – Analyze the problem.
- Start writing steps to resolve the problem in your language.
- Re-analyze the steps and try to add more details.
- Final Review
An algorithm to find the factorial of a number
Step 1: Start Step 2: Declare variables n,factorial and i. Step 3: Initialize variables factorial←1 i←1 Step 4: Read value of n Step 5: Repeat the steps until i=n 5.1: factorial←factorial*i 5.2: i←i+1 Step 6: Display factorial Step 7: Stop