switchout template factorial for double