+ Reply to Thread
Results 1 to 3 of 3

Simple recursion

  1. #1
    Forum Contributor
    Join Date
    05-30-2013
    Location
    France
    MS-Off Ver
    2010
    Posts
    260

    Simple recursion

    Hi,

    I'm trying to understand the flow of recursive formulas and how the variable is being stored in memory. Simple example below :
    Please Login or Register  to view this content.
    which prints:
    Please Login or Register  to view this content.
    If I step into the code, before each print of "I'm looping" the execution leaves the if and the function then comes back inside. How is that possible ? How are "num" and myFact stored ?

    Thanks,
    amphi

  2. #2
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Simple recursion

    It is same as when you call other function. Code passes to called function and returns when complete. In this case you call same function but principle is same (you may look at call stack) - you have chain of 5 calls to function and control pass back up stack when num is 1 for last call.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  3. #3
    Forum Contributor
    Join Date
    05-30-2013
    Location
    France
    MS-Off Ver
    2010
    Posts
    260

    Re: Simple recursion

    Thanks didn't know you could monitor the call stack...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Creating Parent Child Recursion through VBA
    By dinesh_ltjd in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-28-2013, 07:30 AM
  2. Trying to create a macro that uses COUNTBLANK, INDIRECT and recursion.!!!!!!
    By Salsa99 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-21-2012, 06:22 PM
  3. Recursion Problem
    By Losse in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-11-2011, 05:05 PM
  4. procedure :Recursion
    By ElmerS in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-24-2009, 01:31 PM
  5. function:Recursion
    By tido in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-25-2009, 08:18 PM
  6. keep recursion result (a dynamic array) without using global variable
    By lvcha.gouqizi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-25-2005, 03:05 PM
  7. [SOLVED] Abort recursion
    By Mike NG in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2005, 05:05 AM
  8. Recursion
    By Mike NG in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-02-2005, 07:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1