I was wondering because of this: [Trick to find if number is composite or prime](https://math.stackexchange.com/questions/1082306/trick-to-find-if-number-is-composite-or-prime)

Is there any formal method to convert a discrete function to a continuous function. For example take $n!$, how was the gamma function discovered? Is there a general procedure to get the continuous function (which mimics a discrete function)?