impelment factorial by loop