Skip to content

Instantly share code, notes, and snippets.

@zhanhongtao
Created October 11, 2013 04:23
Show Gist options
  • Save zhanhongtao/6929572 to your computer and use it in GitHub Desktop.
Save zhanhongtao/6929572 to your computer and use it in GitHub Desktop.
var f;
f = function ( n ) {
if ( n === 0 ) return 0;
else
return n + f(n-1);
};
var a = f(3);
console.log( 'a: ', a );
var f2 = function( n ) {
if ( n === 0 ) return 0;
else
return n + f2(n-1);
}
var b = f2(3);
console.log( 'b: ', b );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment