Skip to content

Instantly share code, notes, and snippets.

@gpetuhov
Created March 17, 2017 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gpetuhov/de0d00385600db169111bc5ccbee49d9 to your computer and use it in GitHub Desktop.
Save gpetuhov/de0d00385600db169111bc5ccbee49d9 to your computer and use it in GitHub Desktop.
C++ Recursion example
void recur(int n)
{
if (n > 0) {
cout << "1 ";
recur(n-1);
}
return;
}
int main() {
int n = 1; //number of recursions
cout << "Enter number of recursions" << endl;
cin >> n;
recur(n);
cout << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment