cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A263458 Deal a pack of n cards into two piles and gather them up, n/2 times. All n such that this reverses the order of the deck.

This page as a plain text file.
%I A263458 #22 Aug 02 2024 09:29:27
%S A263458 4,6,12,22,28,30,36,46,52,60,70,78,100,102,108,126,148,150,156,166,
%T A263458 172,180,190,196,198,222,228,238,262,268,270,276,292,310,316,348,358,
%U A263458 366,372,382,388,396,420,430,438,460,462,478,486,502,508,540,556,598
%N A263458 Deal a pack of n cards into two piles and gather them up, n/2 times. All n such that this reverses the order of the deck.
%C A263458 This seems to be A003628(n)-1; that is, each element of this sequence is one less than a prime congruent to 5 or 7 modulo 8.
%e A263458 Take a deck of 52 playing cards. Deal it into two piles, then pick up the first pile and put it on top of the other. Do this 26 times. The order of the deck is reversed, so 52 belongs to this sequence.
%e A263458 6 is in the sequence because the 3 shuffles are [1, 2, 3, 4, 5, 6] -> [5, 3, 1, 6, 4, 2] -> [4, 1, 5, 2, 6, 3] -> [6, 5, 4, 3, 2, 1], original reversed. 8 is not in the sequence because the 4 shuffles are [1, 2, 3, 4, 5, 6, 7, 8] -> [7, 5, 3, 1, 8, 6, 4, 2] -> [4, 8, 3, 7, 2, 6, 1, 5] -> [1, 2, 3, 4, 5, 6, 7, 8] -> [7, 5, 3, 1, 8, 6, 4, 2], not the original reversed. - _R. J. Mathar_, Aug 02 2024
%p A263458 isA263458 := proc(n)
%p A263458     local L,itr ;
%p A263458     L := [seq(i,i=1..n)] ;
%p A263458     for itr from 1 to n/2 do
%p A263458         L := pileShuf(L) ; # function code in A323712
%p A263458     end do:
%p A263458     for i from 1 to nops(L) do
%p A263458         if op(-i,L) <> i then
%p A263458             return false ;
%p A263458         end if;
%p A263458     end do:
%p A263458     true ;
%p A263458 end proc:
%p A263458 n := 1;
%p A263458 for k from 2 do
%p A263458     if isA263458(k) then
%p A263458         printf("%d %d\n",n,k) ;
%p A263458         n := n+1 ;
%p A263458     end if;
%p A263458 end do: # _R. J. Mathar_, Aug 02 2024
%o A263458 (Sage)
%o A263458 from itertools import cycle
%o A263458 def into_piles(r,deck):
%o A263458     packs = [[] for i in range(r)]
%o A263458     for card, pack in zip(range(1,deck+1),cycle(range(r))):
%o A263458         packs[pack].insert(0,card)
%o A263458     out = sum(packs,[])
%o A263458     return Permutation(out)
%o A263458 def has_reversing_property(deck):
%o A263458     p = power(into_piles(2,deck), deck/2)
%o A263458     return p==into_piles(1,deck)
%o A263458 [i for i in range(2,400,2) if has_reversing_property(i)]
%Y A263458 Cf. A003628, A373416.
%K A263458 nonn
%O A263458 1,1
%A A263458 _Christian Perfect_, Oct 19 2015