#!/bin/bash
# your code goes here

echo "enter a number"
read n

if [ "$n" -lt 0 ]; then
  echo "factorial is not defined for negative numbers"
  exit 1
fi

fact=1
i="$n"

while [ "$i" -gt 1 ]; do
  fact=$((fact * i))
  i=$((i - 1))
done

echo "the factorial of the given number is $fact"