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.
%I A335504 #13 Jul 11 2020 08:53:39 %S A335504 0,1,1,2,1,1,1,1,0,0,2,24,2,2,1,16,18,1,6,1,42,33,1,1,15,1,24,3,3,1,1, %T A335504 0,1,0,0,0,3,1,195,27,1,465,147,2,6,1002,18,4,42,1,66,2,10,10,738, %U A335504 1660,25,5,180,1,2,15,35,150,4,1490 %N A335504 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 4*x(j-1) by deleting all occurrences of the digit k in base n. %C A335504 T(1,0) = 0 is defined in order to make the triangle of numbers regular. %C A335504 T(n,k) = 1 whenever k is a power of 4 and k>1. %H A335504 Pontus von Brömssen, <a href="/A335504/b335504.txt">Rows n = 1..32, flattened</a> %e A335504 Triangle begins: %e A335504 n\k 0 1 2 3 4 5 6 7 8 9 %e A335504 ----------------------------------------------------- %e A335504 1: 0 %e A335504 2: 1 1 %e A335504 3: 2 1 1 %e A335504 4: 1 1 0 0 %e A335504 5: 2 24 2 2 1 %e A335504 6: 16 18 1 6 1 42 %e A335504 7: 33 1 1 15 1 24 3 %e A335504 8: 3 1 1 0 1 0 0 0 %e A335504 9: 3 1 195 27 1 465 147 2 6 %e A335504 10: 1002 18 4 42 1 66 2 10 10 738 %o A335504 (Python) %o A335504 from sympy.ntheory.factor_ import digits %o A335504 from functools import reduce %o A335504 def drop(x,n,k): %o A335504 # Drop all digits k from x in base n. %o A335504 return reduce(lambda x,j:n*x+j if j!=k else x,digits(x, n)[1:],0) %o A335504 def cycle_length(n,k,m): %o A335504 # Brent's algorithm for finding cycle length. %o A335504 # Note: The function may hang if the sequence never enters a cycle. %o A335504 if (m,n,k)==(5,10,7): %o A335504 return 0 # A little cheating; see A335506. %o A335504 p=1 %o A335504 length=0 %o A335504 tortoise=hare=1 %o A335504 nz=0 %o A335504 while True: %o A335504 hare=drop(m*hare,n,k) %o A335504 while hare and hare%n==0: %o A335504 hare//=n %o A335504 nz+=1 # Keep track of the number of trailing zeros. %o A335504 length+=1 %o A335504 if tortoise==hare: %o A335504 break %o A335504 if p==length: %o A335504 tortoise=hare %o A335504 nz=0 %o A335504 p*=2 %o A335504 length=0 %o A335504 return length if not nz else 0 %o A335504 def A335504(n,k): %o A335504 return cycle_length(n,k,4) if n>1 else 0 %Y A335504 Cf. A335502, A335503, A335505, A335506. %Y A335504 Cf. A243846, A306569, A306773. %K A335504 nonn,base,tabl %O A335504 1,4 %A A335504 _Pontus von Brömssen_, Jun 13 2020