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.

A335505 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 5*x(j-1) by deleting all occurrences of the digit k in base n.

This page as a plain text file.
%I A335505 #21 Jul 13 2020 07:29:43
%S A335505 0,1,1,6,1,1,4,1,1,2,1,1,0,0,0,6,60,6,30,2,1,48,2,3,12,0,1,6,156,14,
%T A335505 22,2,18,1,34,78,12,36,3,48,0,1,138,198,10,684,1,1,2,20,1,2,0,22,1872,
%U A335505 495,2,50,315,0,1,405,245,2780,0,1440
%N A335505 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 5*x(j-1) by deleting all occurrences of the digit k in base n.
%C A335505 T(1,0) = 0 is defined in order to make the triangle of numbers regular.
%C A335505 T(n,k) = 1 whenever k is a power of 5 and k > 1.
%H A335505 Pontus von Brömssen, <a href="/A335505/b335505.txt">Rows n = 1..32, flattened</a>
%e A335505 Triangle begins:
%e A335505    n\k   0    1    2    3    4    5    6    7    8    9
%e A335505   -----------------------------------------------------
%e A335505    1:    0
%e A335505    2:    1    1
%e A335505    3:    6    1    1
%e A335505    4:    4    1    1    2
%e A335505    5:    1    1    0    0    0
%e A335505    6:    6   60    6   30    2    1
%e A335505    7:   48    2    3   12    0    1    6
%e A335505    8:  156   14   22    2   18    1   34   78
%e A335505    9:   12   36    3   48    0    1  138  198   10
%e A335505   10:  684    1    1    2   20    1    2    0   22 1872
%e A335505 T(10,7) = 0 because A335506 never enters a cycle.
%o A335505 (Python)
%o A335505 from sympy.ntheory.factor_ import digits
%o A335505 from functools import reduce
%o A335505 def drop(x,n,k):
%o A335505   # Drop all digits k from x in base n.
%o A335505   return reduce(lambda x,j:n*x+j if j!=k else x,digits(x, n)[1:],0)
%o A335505 def cycle_length(n,k,m):
%o A335505   # Brent's algorithm for finding cycle length.
%o A335505   # Note: The function may hang if the sequence never enters a cycle.
%o A335505   if (m,n,k)==(5,10,7):
%o A335505     return 0 # A little cheating; see A335506.
%o A335505   p=1
%o A335505   length=0
%o A335505   tortoise=hare=1
%o A335505   nz=0
%o A335505   while True:
%o A335505     hare=drop(m*hare,n,k)
%o A335505     while hare and hare%n==0:
%o A335505       hare//=n
%o A335505       nz+=1 # Keep track of the number of trailing zeros.
%o A335505     length+=1
%o A335505     if tortoise==hare:
%o A335505       break
%o A335505     if p==length:
%o A335505       tortoise=hare
%o A335505       nz=0
%o A335505       p*=2
%o A335505       length=0
%o A335505   return length if not nz else 0
%o A335505 def A335505(n,k):
%o A335505   return cycle_length(n,k,5) if n>1 else 0
%Y A335505 Cf. A335502, A335503, A335504, A335506.
%Y A335505 Cf. A243846, A306569, A306773.
%K A335505 nonn,base,tabl
%O A335505 1,4
%A A335505 _Pontus von Brömssen_, Jun 13 2020