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 6188733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:17:15+00:00 2026-05-24T02:17:15+00:00

I was looking at this site: http://rosettacode.org/wiki/Fibonacci_sequence#JavaScript and saw this program: function fib(n) {

  • 0

I was looking at this site: http://rosettacode.org/wiki/Fibonacci_sequence#JavaScript and saw this program:

function fib(n) {
  return function(n,a,b) {
    return n>0 ? arguments.callee(n-1,b,a+b) : a;
  }(n,0,1);
}

How does this work, what are those two arguments (a and b) help. I traced it and still can’t figure out how this works

  • 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-24T02:17:15+00:00Added an answer on May 24, 2026 at 2:17 am

    In the function(n,a,b), n serves as a countdown counter, and a b stores two consecutive Fibonacci numbers for the purpose of computing the next, so when n reaches 0, you have a as the n+1-th Fibonacci number (since the real Fibonacci has two 1s as the beginning).

    E.g., n=4:

    n  a  b
    4  0  1
    3  1  2
    2  2  3
    1  3  5
    0  5  8
    

    As you can see, the value of a and b always equal to the Fibonacci numbers. Also, this is very similar to Functional Programming (as the website stated Scheme programmers).

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

Sidebar

Related Questions

Started looking at the win32 API on this site: http://www.winprog.org/tutorial/start.html I've literally just compiled
I'm looking to replicate the image zooming on this site: http://www.endless.com/adidas-Originals-adiracer-Trefoil-Sneaker/dp/B001I44OIG/183-5587133-4823042?ie=UTF8&cAsin=B001I44O2W&qid=1241466506612&asinTitle=adidas%20Originals%20adiracer%20Trefoil%20HG%20Sneaker&ref_=sw_1&asins=B001I44O2W%2CB001I457WS%2CB001LDJ2MM%2CB001HBH5LS%2CB001O9BJ4C%2CB001VNCNI2%2CB001LDJ7M2%2CB001LNNY44%2CB001LDJ2UE%2CB001OONDCS%2CB001HBH4FA%2CB001OOMWUW&refURL=%252Fb%252F241993011%253F&contextTitle=Search%20Results&fromPage=asinlist&suppressRedirect=1 When you mouse
i am looking at this site: http://cloudexchange.cloudapp.net/stackoverflow/s/84/rising-stars-top-50-users-ordered-on-rep-per-day set nocount on DECLARE @endDate date SELECT
I'm looking to recreate the effect used on this site: http://www.brizk.com/ The site uses
I have read the documentation for Grails and Webtest in this site: http://www.grails.org/plugin/webtest And
looking at this site: http://www.gofundme.com/sign-up/ they have a nice 'amount' input where you can
Hey, I stumbled upon this site looking for solutions for event overlaps in mySQL
I'm looking for suggestions for debugging... If you view this site in Firefox or
looking at this example of the jquery ui slider http://jqueryui.com/demos/slider/#steps i want to be
I stumbled upon this site http://www.swell3d.com/ and I think that in the future we

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.