For more than you ever wanted to know on the mathematics of a perfect shuffle, see this paper:
http://statweb.stanford.edu/~cgates/PERSI/papers/83_05_shuff...
I saw one of the authors, Persi Diaconis, give a talk on this paper, and then perform a perfect shuffle. I was floored.
Re:The Math of Card Shuffling (2018)
by falseprofit on Saturday August 08, 2020 @12:30AM
(#24088974)
Your statement about in shuffles for general n is false. Consider that an in shuffle on n cards is identical to an out shuffle on the middle n of n+2 cards.
Also, the statement in the article is for a random riffle, not a perfect one. Any deck which has only been perfectly riffled is entirely determined.
The in shuffle is n shuffles in general to get back to the start but the out shuffle isn't such a simple pattern.
If you want to make a shuffle that will take _even longer_ to get back to it's starting point, the best you can do is the Landau function which as you can see can get very big: https://oeis.org/A000793/list (I have a calculation of g(52) but not on me right now)