Advertisement
askarulytarlan

рекурсия суммы

Nov 27th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.21 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int x, d, y = 0, s = 0;
  6.  
  7. int sum(int x){
  8. if(x == d){
  9. return d;
  10. }
  11. return x + sum(x+1);
  12. }
  13.  
  14. int main(){
  15. cin >> d;
  16. cout << sum(2);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement