A329596 A variation of Recamán's sequence (A005132): a(0) = 0; a(1) = 1; a(2) = 3; for n > 2, a(n) = sopfr(a(n-1))- sopfr(n) if positive and not already in the sequence, otherwise a(n) = sopfr(a(n-1)) + sopfr(n).
0, 1, 3, 6, 9, 11, 16, 15, 2, 8, 13, 24, 16, 21, 19, 27, 17, 34, 27, 28, 20, 19, 32, 33, 5, 15, 23, 14, 20, 38, 31, 62, 43, 29, 10, 19, 29, 66, 37, 53, 42, 53, 41, 84, 29, 18, 33, 61, 50, 26, 27, 29, 12, 60, 23, 7, 20, 31, 62, 92, 39, 77, 51, 33, 26, 33, 30, 77, 39, 42
Offset: 0
Examples
a(3)=6, factor(6)=[2 3], sum of factor(6) is 5. Then n=4, sum of factor(4) is 2+2=4. 5-4 = 1 but 1 is already in the sequence so a(4)=5+4=9.
Links
- Bence Bernáth, Table of n, a(n) for n = 0..10000
- Bence Bernáth, Table of n, a(n) for n = 0..200000
- Michael De Vlieger, First 65 terms drawn as a spiral, akin to the Harriss drawing at A005132.
- Michael De Vlieger, video of first 128 steps of this sequence, with audio accompaniment generated by aspects of the sequence. Nov 19, 2019.
Programs
-
MATLAB
length_seq=100000; sequence(1)=0; %sum(factor(0))=0 sequence(2)=1; %sum(factor(1))=1 for i1=2:1:length_seq if (sum(factor(sequence(i1)))-sum(factor((i1))))>0 && (ismember((sum(factor(sequence(i1)))-sum(factor((i1)))),sequence)==0) sequence(i1+1)=(sum(factor(sequence(i1)))-sum(factor((i1)))); else sequence(i1+1)=(sum(factor(sequence(i1)))+sum(factor((i1)))); end end result=transpose(sequence);
-
Mathematica
Block[{f}, f[n_] := Total@ Flatten[ConstantArray[#1, #2] & @@@ FactorInteger[n]]; Nest[Append[#1, If[And[#3 >= 0, FreeQ[#1, #3]], #3, f@ #1[[-1]] + f@ #2]] & @@ {#1, #2, f@ #1[[-1]] - f@#2} & @@ {#, Length@ #} &, {0}, 69] ] (* Michael De Vlieger, Nov 19 2019 *)
Comments