A serial flasher who admitted exposing his private parts to a five-year-old girl has been given a six month jail sentence.