### ----------------------------------------------------
### -- OEIS
### -- Licenses: Artistic-2.0
### -- Authors: Tobias Boege
### -- File: t/data/A000045.txt
### ----------------------------------------------------
### -- Chunk 6 of 6
26 2014
%o A000045 (Haskell)
%o A000045 -- Based on code from http://www.haskell.org/haskellwiki/The_Fibonacci_sequence
%o A000045 -- which also has other versions.
%o A000045 fib :: Int -> Integer
%o A000045 fib n = fibs !! n
%o A000045 .. where
%o A000045 .... fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
%o A000045 {- Example of use: map fib [0..38] _Gerald McGarvey_, Sep 29 2009 -}
%o A000045 (Julia)
%o A000045 function fib(n)
%o A000045    F = BigInt[1 1; 1 0]
%o A000045    Fn = F^n
%o A000045    Fn[2, 1]
%o A000045 end
%o A000045 println([fib(n) for n in 0:38]) # _Peter Luschny_, Feb 23 2017
%o A000045 (GAP)
%o A000045 Fib:=[0,1];; for n in [3..10^3] do Fib[n]:=Fib[n-1]+Fib[n-2]; od; Fib;  #  _Muniru A Asiru_, Sep 03 2017
%o A000045 (Scheme)
%o A000045 ;; The following definition uses macro definec for the memoization (caching) of the results. See http://oeis.org/wiki/Memoization#Scheme
%o A000045 (definec (A000045 n) (if (< n 2) n (+ (A000045 (- n 1)) (A000045 (- n 2))))) ;; _Antti Karttunen_, Oct 06 2017
%o A000045 (Scala) def fibonacci(n: BigInt): BigInt = {
%o A000045   val zero = BigInt(0)
%o A000045   def fibTail(n: BigInt, a: BigInt, b: BigInt): BigInt = n match {
%o A000045     case `zero` => a
%o A000045     case _ => fibTail(n - 1, b, a + b)
%o A000045   }
%o A000045   fibTail(n, 0, 1)
%o A000045 } // Based on "Case 3: Tail Recursion" from Carrasquel (2016) link
%o A000045 (0 to 49).map(fibonacci(_)) // _Alonso del Arte_, Apr 13 2019
%Y A000045 Cf. A039834 (signed Fibonacci numbers), A001690 (complement), A000213, A000288, A000322, A000383, A060455, A030186, A020695, A020701, A071679, A099731, A100492, A094216, A094638, A000108, A101399, A101400, A001611, A000071, A157725, A001911, A157726, A006327, A157727, A157728, A157729, A167616, A059929, A144152, A152063, A114690, A003893, A000032, A060441, A000930, A003269, A000957, A057078, A007317, A091867, A104597, A249548, A262342, A001060, A022095, A072649.
%Y A000045 First row of arrays A103323, A172236, A234357. Second row of arrays A099390, A048887, and A092921 (k-generalized Fibonacci numbers).
%Y A000045 Cf. A001175 (Pisano periods), A001177 (Entry points), A001176 (number of zeros in a fundamental period).
%Y A000045 Fibonacci-Pascal triangles: A027926, A036355, A037027, A074829, A105809, A109906, A111006, A114197, A162741, A228074.
%Y A000045 Boustrophedon transforms: A000738, A000744.
%Y A000045 Powers: A103323, A105317, A254719.
%Y A000045 Numbers of prime factors: A022307 and A038575.
%Y A000045 Cf. A163733.
%K A000045 nonn,core,nice,easy,hear
%O A000045 0,4
%A A000045 _N. J. A. Sloane_, 1964

# Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE



