solved small_factorial in Python and Java