The three-pile trick is a well-known card trick performed with a deck of 27 cards which dates back to the early seventeenth century at least and its objective is to uncover the card chosen by a volunteer. The main purpose of this research is to give a mathematical generalization of the three-pile trick for any deck of ab cards with a, b ≥ 2 any integers by means of a finite family of simple discrete functions. Then, it is proved each of these functions has just one or two stable fixed points. Based on this findings a list of 222 (three-pile trick)-type brand new card tricks was generated for either a package of 52 playing cards or any appropriate portion of it with a number of piles between 3 and 7. It is worth noting that all the card tricks on the list share the three main properties that have characterized the three-pile trick: simplicity, self-performing and infallibility. Finally, a general performing protocol, useful for magicians, is given for all the cases. All the employed math techniques involve naive theory of discrete functions, basic properties of the quotient and remainder of the division of integers and modular arithmetic.
 Bachet, C. G. Probl`emes plaisans et d´electables, qui se font par les nombres, partie recueillis de divers autheurs, et inventez de nouveau, avec leur d´emonstration, par Claude Gaspar Bachet, Sr. de M´eziriac. Tr`es utiles pour toutes sortes de personnes curieuses qui se servent d’arithm´etique (1612). Edition consulted: C. Bachet, Probl`emes plaisants et d´electables qui se font par les nombres, Gauthier-Villars, Paris, 1884.
 Ball, W. W. R., Coxeter, H. S. M. Mathematical Recreations and Essays and Problems of Past and Present Times, Macmillan, London & New York, 1892.
 Bolker, E. “Gergonne’s card trick, positional notation, and radix sort”, Mathematics Magazine, 83, 46-49, 2010.
 Champanerkar, J., Jani, M. “Stable Fixed Points of Card Trick Functions”, arXiv:1308.3396v1[math.HO], 1-10, 2013.