#!/bin/bash
echo "Enter a number: "
read number
factorial=1
function FactorialMethod()
{
num=$1
while [[ $num -ge 1 ]]
do
factorial=$(( $factorial*$num ))
num=$(($num - 1))
done
return $factorial
}
FactorialMethod $number
result=$?
echo "Factorial of "$number" is "$result
When I run this code and I input numbers from 0 to 5 I'm getting correct answers. However when I input numbers from 6 and above I'm getting wrong answers... What is wrong with my code?
I'm new to StackOverflow so I'm sorry if this was a repeated question and thank you for your help :)