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.
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, 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, 495, 2, 50, 315, 0, 1, 405, 245, 2780, 0, 1440
Offset: 1
Examples
Triangle begins: n\k 0 1 2 3 4 5 6 7 8 9 ----------------------------------------------------- 1: 0 2: 1 1 3: 6 1 1 4: 4 1 1 2 5: 1 1 0 0 0 6: 6 60 6 30 2 1 7: 48 2 3 12 0 1 6 8: 156 14 22 2 18 1 34 78 9: 12 36 3 48 0 1 138 198 10 10: 684 1 1 2 20 1 2 0 22 1872 T(10,7) = 0 because A335506 never enters a cycle.
Links
- Pontus von Brömssen, Rows n = 1..32, flattened
Programs
-
Python
from sympy.ntheory.factor_ import digits from functools import reduce def drop(x,n,k): # Drop all digits k from x in base n. return reduce(lambda x,j:n*x+j if j!=k else x,digits(x, n)[1:],0) def cycle_length(n,k,m): # Brent's algorithm for finding cycle length. # Note: The function may hang if the sequence never enters a cycle. if (m,n,k)==(5,10,7): return 0 # A little cheating; see A335506. p=1 length=0 tortoise=hare=1 nz=0 while True: hare=drop(m*hare,n,k) while hare and hare%n==0: hare//=n nz+=1 # Keep track of the number of trailing zeros. length+=1 if tortoise==hare: break if p==length: tortoise=hare nz=0 p*=2 length=0 return length if not nz else 0 def A335505(n,k): return cycle_length(n,k,5) if n>1 else 0
Comments