login
Number of Fibonacci numbers <= n.
19

%I #39 Nov 04 2024 16:31:10

%S 1,3,4,5,5,6,6,6,7,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,

%T 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,

%U 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11

%N Number of Fibonacci numbers <= n.

%C 1 is counted twice as a Fibonacci number: F(1) = F(2) = 1. - _Alois P. Heinz_, Nov 04 2024

%H Michael De Vlieger, <a href="/A108852/b108852.txt">Table of n, a(n) for n = 0..10000</a>

%H Dorin Andrica, Ovidiu Bagdasar, and George Cătălin Tųrcąs, <a href="https://doi.org/10.2478/auom-2021-0002">On some new results for the generalised Lucas sequences</a>, An. Şt. Univ. Ovidius Constanţa (Romania, 2021) Vol. 29, No. 1, 17-36.

%F G.f.: (Sum_{n>=0} x^Fibonacci(n))/(1-x). - _Vladeta Jovovic_, Nov 27 2005

%F a(n) = 1+floor(log_phi((sqrt(5)*n+sqrt(5*n^2+4))/2)), n>=0, where phi is the golden ratio. Alternatively, a(n) = 1+floor(arcsinh(sqrt(5)*n/2)/log(phi)). Also a(n) = A072649(n)+2. - _Hieronymus Fischer_, May 02 2007

%F a(n) = 1+floor(log_phi(sqrt(5)*n+1)), n>=0, where phi is the golden ratio. - _Hieronymus Fischer_, Jul 02 2007

%p a:= proc(n) option remember; `if`(n<2, 2*n+1, a(n-1)+

%p (t-> `if`(issqr(t+4) or issqr(t-4), 1, 0))(5*n^2))

%p end:

%p seq(a(n), n=0..100); # _Alois P. Heinz_, Nov 04 2024

%t fibPi[n_] := 1 + Floor[ Log[ GoldenRatio, 1 + n*Sqrt@ 5]]; Array[fibPi, 80, 0] (* _Robert G. Wilson v_, Aug 03 2014 *)

%o (Haskell) fibs :: [Integer]

%o fibs = 0 : 1 : zipWith (+) fibs (tail fibs)

%o fibs_to :: Integer -> Integer

%o fibs_to n = length $ takeWhile (<= n) fibs

%o (Python)

%o def A108852(n):

%o a, b, c = 0, 1, 0

%o while a <= n:

%o a, b = b, a+b

%o c += 1

%o return c # _Chai Wah Wu_, Nov 04 2024

%Y Cf. A000045, A001622, A060384, A072649.

%Y Partial sums of A104162.

%K nonn,changed

%O 0,2

%A Michael C. Vanier (mvanier(AT)cs.caltech.edu), Nov 27 2005