login
a(n) is the index of the n-th occurrence of 1 in A365203.
1

%I #35 Jan 01 2024 11:55:28

%S 1,14,53,109,221,445,893,1789,3581,7165,14333,28669,84530,295033,

%T 830369,1660741,4755764,10372048,28287409,56574821,153253317,

%U 323636916,848150626,2217511139,6534867338,20173498129,40346996261,120496984345

%N a(n) is the index of the n-th occurrence of 1 in A365203.

%H Chai Wah Wu, <a href="/A365199/b365199.txt">Table of n, a(n) for n = 1..31</a>

%e a(1) = 1 since A365203(1) = 1 (1st occurrence of 1).

%e a(2) = 14 since A365203(14) = 1 (2nd occurrence of 1).

%e a(3) = 53 since A365203(53) = 1 (3rd occurrence of 1).

%e a(4) = 109 since A365203(109) = 1 (4th occurrence of 1).

%p A365203 := proc(n) option remember; if n = 1 then 1; elif procname(n - 1) < n then procname(n - 1) + n; elif n = procname(n - 1) then n*n; elif irem(procname(n - 1), n) = 0 then procname(n - 1)/n; else procname(n - 1) - n; end if; end proc;

%p A365199 := proc(n) if A365203(n) = 1 then n; end if; end proc;

%p seq(A365199(n), n = 1 .. 200000000);

%o (Python)

%o from itertools import count,islice

%o def A365199_gen(): # generator of terms

%o yield (a:=1)

%o for n in count(2):

%o if a<n:

%o a += n

%o elif a==n:

%o a = n**2

%o elif a%n:

%o a -= n

%o else:

%o a //= n

%o if a == 1:

%o yield n

%o A365199_list = list(islice(A365199_gen(),10)) # _Chai Wah Wu_, Sep 23 2023

%Y Cf. A365203.

%K nonn,hard

%O 1,2

%A _Felix Huber_, Aug 26 2023

%E a(22)-a(23) from _Michel Marcus_, Aug 28 2023

%E a(24)-a(28) from _Chai Wah Wu_, Sep 23 2023