A348483 a(1) = 1; if the sum of the digits of 2*a(n-1) + 1 is not yet in the sequence then a(n) = 2*a(n-1) + 1; otherwise a(n) is the sum of digits of a(n-1).
1, 3, 7, 15, 6, 13, 4, 9, 19, 10, 21, 43, 87, 175, 351, 703, 1407, 12, 25, 51, 103, 207, 415, 831, 1663, 16, 33, 67, 135, 271, 543, 1087, 2175, 4351, 8703, 18, 37, 75, 151, 303, 607, 1215, 2431, 4863, 9727, 19455, 24, 49, 99, 199, 399, 799, 1599, 3199, 22, 45
Offset: 1
Examples
a(4) = 15 because it is the double + 1 of a(3) = 7. a(5) = 6 and not 31 because the sum of the digits of 15, 1 + 5 = 6 and 6 is not yet in the sequence. a(6) = 13 because it is the double + 1 of a(5) = 6. Written as an irregular triangle the sequence begins: 1, 3, 7, 15; 6, 13; 4, 9, 19; 10, 21, 43, 87, 175, 351, 703, 1407; 12, 25, 51, 103, 207, 415, 831, 1663; 16, 33, 67, 135, 271, 543, 1087, 2175, 4351, 8703; 18, 37, 75, 151, 303, 607, 1215, 2431, 4863, 9727, 19455; 24, 49, 99, 199, 399, 799, 1599, 3199; ...
Programs
-
Mathematica
seq[len_] := Module[{s = {1}, k, d}, While[Length[s] < len, k = s[[-1]]; If[MemberQ[s, (d = Plus @@ IntegerDigits[k])], AppendTo[s, 2*k + 1], AppendTo[s, d]]]; s]; seq[50] (* Amiram Eldar, Oct 21 2021 *)
-
PARI
lista(nn) = my(s, v=List([1])); for(n=1, nn, if(setsearch(vecsort(v), s=sumdigits(v[n])), listput(v, 2*v[n]+1), listput(v, s))); Vec(v); \\ Jinyuan Wang, Oct 21 2021
Comments