factorial function in cpp