OFFSET
1,2
COMMENTS
a(1)=1; thereafter a(n) is the least positive number not yet in the sequence such that Sum_{i=1..n} a(i) == 1 mod n+1.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..10000
Muharem Avdispahić and Faruk Zejnulahi, An integer sequence with a divisibility property, Fibonacci Quarterly, Vol. 58:4 (2020), 321-333.
J. Shallit, Proving properties of some greedily-defined integer recurrences via automata theory, arXiv:2308.06544 [cs.DM], August 12 2023.
FORMULA
Theorem 1 of Avdispahić and Zejnulahi gives an explicit formula involving Fibonacci numbers.
MAPLE
A000045_inv := proc(n)
local k ;
for k from 0 do
if combinat[fibonacci](k) = n then
return k;
elif combinat[fibonacci](k) > n then
return -1;
end if;
end do:
end proc:
A000071_inv := proc(n)
local k ;
for k from 0 do
if combinat[fibonacci](k)-1 = n then
return k;
elif combinat[fibonacci](k)-1 > n then
return -1;
end if;
end do:
end proc:
A000201_inv := proc(n)
local k, w ;
for k from 1 do
w := floor(k*(1+sqrt(5))/2) ;
if w = n then
return k;
elif w > n then
return -1;
end if;
end do:
end proc:
A001950_inv := proc(n)
local k, w ;
for k from 1 do
w := floor(k*(3+sqrt(5))/2) ;
if w = n then
return k;
elif w > n then
return -1;
end if;
end do:
end proc:
A340510 := proc(n)
local k ;
if n = 1 then
1;
else
k := A000045_inv(n) ;
if k > 2 then
return combinat[fibonacci](k+1) ;
end if;
k := A000071_inv(n) ;
if k > 4 then
return combinat[fibonacci](k-1)-1 ;
end if;
k := A000201_inv(n) ;
if k > 0 then
return floor(k*(3+sqrt(5))/2) ;
end if;
k := A001950_inv(n) ;
return floor(k*(1+sqrt(5))/2) ;
end if;
end proc:
seq(A340510(n), n=1..50) ; # R. J. Mathar, Jan 30 2024
MATHEMATICA
a[n_] := a[n] = Switch[n, 1, 1, 2, 3, 3, 5, 4, 2, _, Module[{aa, ss, dd, an}, aa = Array[a, n-1]; ss = Sort[aa]; dd = Differences[ss]; For[an = Select[Transpose[{Rest[ss], dd}], #[[2]] == 1 &][[-1, 1]]+1, True, an++, If[FreeQ[aa = Array[a, n-1], an], If[Mod[Total[aa] + an, n+1] == 1, Return[an]]]]]];
Table[Print[n, " ", a[n]]; a[n], {n, 1, 100}] (* Jean-François Alcover, Jan 31 2021 *)
CROSSREFS
KEYWORD
nonn,hear
AUTHOR
N. J. A. Sloane, Jan 28 2021
EXTENSIONS
More terms from Alois P. Heinz, Jan 28 2021
STATUS
approved