Fix logic of factorial example