login
a(1) = 1. If a(n) is prime, a(n+1) = 2*a(n); otherwise, a(n+1) = 2*a(n) + 1.
1

%I #19 Jan 22 2023 16:30:27

%S 1,3,6,13,26,53,106,213,427,855,1711,3423,6847,13695,27391,54783,

%T 109567,219134,438269,876539,1753079,3506159,7012318,14024637,

%U 28049275,56098551,112197103,224394207,448788415,897576831,1795153663,3590307326

%N a(1) = 1. If a(n) is prime, a(n+1) = 2*a(n); otherwise, a(n+1) = 2*a(n) + 1.

%F a(n) = floor(c*2^n), where c = 0.8359335658... - _Lorenzo Sauras Altuzarra_, Jan 01 2023

%p a := proc(n)

%p local c, k:

%p c, k := 1, 1:

%p while c < n do

%p if isprime(k) then k := 2*k: else k := 2*k+1: fi:

%p c := c+1: od:

%p k: end: # _Lorenzo Sauras Altuzarra_, Jan 02 2023

%t NestList[If[PrimeQ[#],2#,2#+1]&,1,40] (* _Harvey P. Dale_, Sep 01 2017 *)

%Y Cf. A125050.

%K nonn

%O 1,2

%A _Franklin T. Adams-Watters_, Nov 17 2006