Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #19 Jan 21 2023 01:59:34
%S 1,2,3,34,5,610,377,8,89,610,4181,121393,13,144,1597,10946,1597,4181,
%T 1597,832040,21,514229,233,2584,2584,28657,28657,2584,121393,832040,
%U 317811,832040,233,34,3524578,46368,377,46368,121393,832040,4181,514229
%N a(n) is the smallest Fibonacci number that is obtained by placing digits anywhere in n; a(n) = n if n is a Fibonacci number.
%H Robert Israel, <a href="/A080471/b080471.txt">Table of n, a(n) for n = 1..10000</a>
%p IsSubList:= proc(T, S)
%p local i;
%p if T = [] then return true fi;
%p if S = [] then return false fi;
%p i:= ListTools:-Search(T[1],S);
%p if i = 0 then false else procname(T[2..-1],S[i+1..-1]) fi
%p end proc:
%p f:= proc(n) local T,S,k,v;
%p T:= convert(n,base,10);
%p for k from 1 do
%p v:= combinat:-fibonacci(k);
%p S:= convert(v,base,10);
%p if IsSubList(T,S) then return v fi
%p od
%p end proc:
%p map(f, [$1..100]); # _Robert Israel_, Mar 10 2020
%t a[n_] := Block[{p = RegularExpression[ StringJoin @@ Riffle[ ToString /@ IntegerDigits[ n], ".*"]], f, k=2}, While[! StringContainsQ[ ToString[f = Fibonacci[ k++]], p]]; f]; Array[a, 42] (* _Giovanni Resta_, Mar 10 2020 *)
%o (Python)
%o def dmo(n, t):
%o if t < n: return False
%o while n and t:
%o if n%10 == t%10:
%o n //= 10
%o t //= 10
%o return n == 0
%o def fibo(f=1, g=2):
%o while True: yield f; f, g = g, f+g
%o def a(n):
%o return next(f for f in fibo() if dmo(n, f))
%o print([a(n) for n in range(1, 77)]) # _Michael S. Branicky_, Jan 21 2023
%Y Cf. A068164, A068165, A080470.
%K base,nonn
%O 1,2
%A _Amarnath Murthy_, Mar 07 2003
%E Corrected and extended by _Ray Chandler_, Oct 11 2003