Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4623648
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:01:08+00:00 2026-05-22T03:01:08+00:00

How would the Fibonacci’s closed form code look like in haskell ?

  • 0

How would the Fibonacci’s closed form code look like in haskell?

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:01:09+00:00Added an answer on May 22, 2026 at 3:01 am

    Trivially, Binet’s formula, from the Haskell wiki page is given in Haskell as:

    fib n = round $ phi ^ n / sq5
      where
        sq5 = sqrt 5 
        phi = (1 + sq5) / 2
    

    Which includes sharing of the result of the square root. For example:

    *Main> fib 1000
    4346655768693891486263750038675
    5014010958388901725051132915256
    4761122929200525397202952340604
    5745805780073202508613097599871
    6977051839168242483814062805283
    3118210513272735180508820756626
    59534523370463746326528
    

    For arbitrary integers, you’ll need to be a bit more careful about the conversion to floating point values.
    Note that Binet’s value differs from the recursive formula by quite a bit at this point:

    *Main> let fibs = 0 : 1 : zipWith (+) fibs (tail fibs) 
    *Main> fibs !!   1000
    4346655768693745643568852767504
    0625802564660517371780402481729
    0895365554179490518904038798400
    7925516929592259308032263477520
    9689623239873322471161642996440
    9065331879382989696499285160037
    04476137795166849228875
    

    You may need more precision 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would having a nice little feature that makes it quicker to write code like
I am looking through some example Fibonacci sequence clojure code: (def fibs (lazy-cat [1
Please explain this simple code: public int fibonacci(int n) { if(n == 0) return
What sequence of operations would give the worst case for fibonacci heaps? Where each
What would be the most efficient way to calculate the sum of Fibonacci numbers
here is what I thought would be a correct and useful definition of fibonacci
I'm making a fibonacci heap implementation in Haskell, and I'm not sure exactly what
I get a code for Fibonacci Heap. This code uses the follow function to
Please could you help me with displaying the first 10 Fibonacci numbers. My code
I wrote the following code to find the 1500000th Fibonacci number(Please ignore horrible indenting,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.