%I #13 Jan 06 2017 23:06:00
%S 1,4,7,12,17,22,27,43,51,59,67,75,83,122,135,148,161,174,187,200,213,
%T 226,239,344,365,386,407,428,449,470,491,512,533,554,575,596,617,638,
%U 659,931,965,999,1033,1067,1101,1135,1169,1203,1237,1271
%N Least k such that A249783(k) = n.
%C It appears that a(n) exists for each n, and that the sequence is increasing.
%H Charles R Greathouse IV, <a href="/A246399/b246399.txt">Table of n, a(n) for n = 1..1000</a>
%H <a href="/index/Com#complexity">Index to sequences related to the complexity of n</a>
%e a(3) = 7 because the Fibonacci-like sequence 2, 1, 3, 4, 7, 11, ... contains 7 and the sum of the first two terms is 3, while no smaller sequences work. (All terms must be nonnegative.)
%t A249783[n_] := A249783[n] = Module[{a, k, A, B}, If[n<2, Return[n]]; For[k = 1, k <= n-1, k++, For[a=0, a <= k-1, a++, A = a; B = k-A; While[B<n, {A, B} = {B, A+B}]; If[B==n, Return[k]]]]; n]; a[1]=1; a[n_] := a[n] = For[k = a[n-1], True, k++, If[A249783[k] == n, Return[k]]]; Array[a, 50] (* _Jean-François Alcover_, Jan 06 2017, adapted from PARI *)
%o (PARI) A054495(n)=fordiv(n,d,if(A010056(n/d),return(d)))
%o A249783(n)=if(n<2,return(n));for(k=1,n-1,for(a=0,k-1,my(A=a,B=k-A);while(B<n,[A,B]=[B,A+B]);if(B==n,return(k))));n
%o v=vector(100);least=1;for(n=1,1e7,if(aa(n)<least,next);t=a(n);if(t>=least&&t<=#v&&v[t]==0,v[t]=n;while(v[least],if(least++>#v,return(v)))))
%Y Cf. A249783, A054495.
%K nonn
%O 1,2
%A _Charles R Greathouse IV_, Nov 13 2014