Skip to content

Instantly share code, notes, and snippets.

@kdabir
Created March 14, 2012 14:30
Show Gist options
  • Save kdabir/2036868 to your computer and use it in GitHub Desktop.
Save kdabir/2036868 to your computer and use it in GitHub Desktop.
Sum of first n numbers (recursive)
/** sum of first n number */
int add(int num){
return (num)?num + add(num-1):num;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment