Created
May 24, 2020 13:47
-
-
Save invatainfo/52dc9f3d7408fd3ba778ebf018b9ea87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int suma(int n) | |
{ | |
if(n==0) | |
return 0; //conditia de oprire (nu are sens sa mergem mai departe de 0) | |
else | |
return n+suma(n-1); //formula de recurenta | |
} | |
int n; | |
int main() | |
{ | |
cin>>n; | |
cout<<suma(n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment