We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Functional Programming
  3. Recursion
  4. Fibonacci Numbers
  5. Discussions

Fibonacci Numbers

Problem
Submissions
Leaderboard
Discussions

Sort 55 Discussions, By:

recency

Please Login in order to post a comment

  • lematero
    3 weeks ago+ 0 comments

    F# solution

    open System
    
    let rec f n =
        match n with
        | 1 -> 0
        | 2 -> 1
        | n -> f (n - 1) + f (n - 2)
    
    [<EntryPoint>]
    let main argv =
        Console.ReadLine() |> int |> f |> Console.WriteLine
    
        0
    
    0|
    Permalink
  • tashacourtney
    2 months ago+ 0 comments

    This is a great source here.

    0|
    Permalink
  • manoncamus
    2 months ago+ 0 comments

    I am a new learner here , can you help me.

    0|
    Permalink
  • psihosocial
    4 months ago+ 0 comments
    Simple Haskell solution
    fibs = 0 : 1 : [ a + b | (a, b) <- zip fibs (tail fibs)]
    fib n = last $ take n fibs 
    
    1|
    Permalink
  • dgmatos30
    7 months ago+ 0 comments

    That's a simple haskell solution which matches the fibonacci formula:

    fib(n) Sequence
    Nth: 1 2 3 4 5 6 7 08 09 10 11 12 [...]
    Terms: 0 1 1 2 3 5 8 13 21 34 55 89 [...]

    fib 1 = 0
    fib 2 = 1
    fib n = fib(n-1) + fib(n-2)
    
    0|
    Permalink
Load more conversations

Need Help?


View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy