Factorial with ranges