Declarative and imperative Factorial program