Skip to content

Instantly share code, notes, and snippets.

@kt-aakash
Created July 26, 2017 09:34
Show Gist options
  • Save kt-aakash/446a1f7f1a5e35a3cfc2f3ed40b6b5d3 to your computer and use it in GitHub Desktop.
Save kt-aakash/446a1f7f1a5e35a3cfc2f3ed40b6b5d3 to your computer and use it in GitHub Desktop.
A virtual illustration of a recursive function
function factorialize(3) {
if(3>1)
return 3*factorialize(2){ //**********This staten=ment gets executed SINCE 3 > 1 is true
if(2>1)
return 2*factorialize(1){ //**********This staten=ment gets executed SINCE 2 > 1 is true
if(1>1)
return 1*factorialize(0);
else
return 1; //**********This staten=ment gets executed SINCE 1 is not greater than 1
};
else
return 1;
};
else
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment