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.

A319864 Exponents of the final nontrivial entry of the iterated Stern sequence; a(n) = log_2 min{s^k(n) : k > 0, s^k(n) > 1}, where s(n) = A002487(n).

This page as a plain text file.
%I A319864 #31 May 19 2023 01:44:25
%S A319864 1,1,2,1,1,1,3,2,1,1,1,1,1,2,4,1,2,1,1,3,1,1,1,1,1,3,1,1,2,1,5,1,1,2,
%T A319864 2,1,1,1,1,1,3,1,1,1,1,2,1,2,1,1,1,1,3,1,1,1,1,1,2,2,1,1,6,1,1,1,1,1,
%U A319864 2,1,2,2,1,2,1,1,1,1,1,1,1,1,3,3,1,2,1,1,1,1,1,4,2,1,1,1,2,4,1,1,1,1,1,2,1,3,3,1,1
%N A319864 Exponents of the final nontrivial entry of the iterated Stern sequence; a(n) = log_2 min{s^k(n) : k > 0, s^k(n) > 1}, where s(n) = A002487(n).
%C A319864 Let s(n) = A002487(n). Since s(n) < n for n > 1, iterating A002487 from any starting point eventually yields the fixed point 1 = s(1). Since s^-1(1) consists of the powers of 2, min{s^k(n) : k > 0, s^k(n) > 1} is a nontrivial power of 2 for any n > 1. Hence, the entries of this sequence are integers.
%C A319864 Since a(2^m) = m, every positive integer appears in this sequence.
%C A319864 Question: What is the asymptotic density of the number 1 in this sequence? Of the first 10^6 entries, more than 74% are 1.
%e A319864 Letting s(m) = A002487(m), we have s(7) = 3, s(3) = 2, and s(2) = 1. Hence, a(7) = log_2(2) = 1.
%t A319864 s[n_] := If[n<2, n, If[EvenQ[n], s[n/2], s[(n-1)/2] + s[(n+1)/2]]];  a[n_] := Module[{nn = s[n]}, If[nn==1, Log2[n], a[nn]]]; Array[a, 100, 2] (* _Amiram Eldar_, Nov 22 2018 *)
%o A319864 (Python)
%o A319864 from math import log
%o A319864 def s(n): return n if n<2 else s(n//2) if n%2==0 else s((n-1)//2)+s((n+1)//2)
%o A319864 def a(n): nn = s(n); return int(log(n,2)) if nn==1 else a(nn)
%o A319864 print([a(n) for n in range(2, 100)])
%o A319864 (Python)
%o A319864 from functools import reduce
%o A319864 def A319864(n):
%o A319864     while (m:=sum(reduce(lambda x,y:(x[0],x[0]+x[1]) if int(y) else (x[0]+x[1],x[1]),bin(n)[-1:2:-1],(1,0)))) > 1:
%o A319864         n = m
%o A319864     return n.bit_length()-1 # _Chai Wah Wu_, May 18 2023
%o A319864 (PARI) s(n) = if( n<2, n>0, s(n\2) + if( n%2, s(n\2 + 1))); \\ A002487
%o A319864 a(n) = while((nn = s(n)) != 1, n = nn); valuation(n, 2); \\ _Michel Marcus_, Nov 23 2018
%Y A319864 Cf. A002487.
%K A319864 nonn
%O A319864 2,3
%A A319864 _Oliver Pechenik_, Sep 29 2018