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.

A335502 Triangle read by rows, 0 <= k < n, n >= 1: T(n,k) is the eventual period of the sequence x(j) (or 0 if x(j) never enters a cycle) defined as follows: x(0) = 1 and for j > 1 x(j) is obtained from 2*x(j-1) by deleting all occurrences of the digit k in base n.

This page as a plain text file.
%I A335502 #13 Jul 11 2020 08:53:36
%S A335502 0,1,1,4,1,1,2,1,1,0,4,1,1,3,1,12,2,1,6,1,4,78,1,1,6,1,3,6,3,1,1,0,1,
%T A335502 0,0,0,6,1,1,18,1,4,36,4,1,36,4,1,4,1,8,4,72,1,540,100,1,1,16,1,4,17,
%U A335502 0,1,8,4,90,2,1,12,1,4,14,6,1,4,4,240
%N A335502 Triangle read by rows, 0 <= k < n, n >= 1: T(n,k) is the eventual period of the sequence x(j) (or 0 if x(j) never enters a cycle) defined as follows: x(0) = 1 and for j > 1 x(j) is obtained from 2*x(j-1) by deleting all occurrences of the digit k in base n.
%C A335502 T(1,0) = 0 is defined in order to make the triangle of numbers regular.
%C A335502 One way of getting T(n,k) = 0 is to have x(j) = x(i)*n^e for some j > i and e > 0. For k < n <= 48, this is the only way to get T(n,k) = 0 (but see A335506 for another situation where the x-sequence is not periodic).
%C A335502 T(n,k) = 1 whenever k is a power of 2 and k > 1.
%C A335502 It seems that k = 0 and k = n-1 often lead to particularly long cycles.
%H A335502 Pontus von Brömssen, <a href="/A335502/b335502.txt">Rows n = 1..48, flattened</a>
%e A335502 Triangle begins:
%e A335502    n\k  0   1   2   3   4   5   6   7   8   9  10  11
%e A335502   ---------------------------------------------------
%e A335502    1:   0
%e A335502    2:   1   1
%e A335502    3:   4   1   1
%e A335502    4:   2   1   1   0
%e A335502    5:   4   1   1   3   1
%e A335502    6:  12   2   1   6   1   4
%e A335502    7:  78   1   1   6   1   3   6
%e A335502    8:   3   1   1   0   1   0   0   0
%e A335502    9:   6   1   1  18   1   4  36   4   1
%e A335502   10:  36   4   1   4   1   8   4  72   1 540
%e A335502   11: 100   1   1  16   1   4  17   0   1   8   4
%e A335502   12:  90   2   1  12   1   4  14   6   1   4   4 240
%e A335502 For n = 10 and k = 5, the x-sequence starts 1, 2, 4, 8, 16, 32, 64, 128, 26, 2, and then repeats with a period of 8, so T(10,5) = 8.
%e A335502 T(10,0) = 36, because A242350 eventually enters a cycle of length 36.
%e A335502 For n=11 and k=7, the x-sequence starts (in base 11) 1, 2, 4, 8, 15, 2A, 59, 10. Disregarding trailing zeros, the sequence then repeats with period 7 and x(i+7*j) = x(i)*11^j for positive i and j. The x-sequence itself is therefore not eventually periodic, so T(11,7)=0.
%o A335502 (Python)
%o A335502 from sympy.ntheory.factor_ import digits
%o A335502 from functools import reduce
%o A335502 def drop(x,n,k):
%o A335502   # Drop all digits k from x in base n.
%o A335502   return reduce(lambda x,j:n*x+j if j!=k else x,digits(x, n)[1:],0)
%o A335502 def cycle_length(n,k,m):
%o A335502   # Brent's algorithm for finding cycle length.
%o A335502   # Note: The function may hang if the sequence never enters a cycle.
%o A335502   if (m,n,k)==(5,10,7):
%o A335502     return 0 # A little cheating; see A335506.
%o A335502   p=1
%o A335502   length=0
%o A335502   tortoise=hare=1
%o A335502   nz=0
%o A335502   while True:
%o A335502     hare=drop(m*hare,n,k)
%o A335502     while hare and hare%n==0:
%o A335502       hare//=n
%o A335502       nz+=1 # Keep track of the number of trailing zeros.
%o A335502     length+=1
%o A335502     if tortoise==hare:
%o A335502       break
%o A335502     if p==length:
%o A335502       tortoise=hare
%o A335502       nz=0
%o A335502       p*=2
%o A335502       length=0
%o A335502   return length if not nz else 0
%o A335502 def A335502(n,k):
%o A335502   return cycle_length(n,k,2) if n>1 else 0
%Y A335502 Cf. A242350.
%Y A335502 Cf. A335503, A335504, A335505, A335506.
%Y A335502 Cf. A243846, A306569, A306773.
%K A335502 nonn,base,tabl
%O A335502 1,4
%A A335502 _Pontus von Brömssen_, Jun 13 2020