Professional Documents
Culture Documents
21bce0427 VL2023240101126 Ast01
21bce0427 VL2023240101126 Ast01
NAME: Chethan N V
REG.NO: 21BCE0427
Slot: L43+L44
Algorithm:
Step 1: Start
Step 2: Open file with sh extension
Step 3: write shell programming
Step 3: Input n
Step 4: initialize factorial to 1
Step 5: declare for loop from i=1 to n
Step 6: Print factorial
Step 7: Stop
Program:
echo "Name: Chethan N V"
echo "Reg No: 21BCE0427"
echo "Enter a number to find factorial"
read n
f=1
for((i=1;i<=n;i++))
{
f=$(bc <<< "$f*$i")
}
echo $n"! = "$f
Screenshots:
Sample Input 1:
25
Sample Output 1:
25! = 15511210043330985984000000
Sample Input 2:
10
Sample Output 2:
10! = 3628800