flash moved out of if condition
fixed a bug with factorial