View Code of Problem 30

#include <iostream>
using namespace std;
int n;
int digui(int n,int total){
	total+=n;
	if(n==1) return total;
	else
		return digui(n-1,total);
}
int main(void){
	while(cin>>n){
	int total=0;
	cout<<digui(n,total)<<endl;
}
	return 0;
} 

Double click to view unformatted code.


Back to problem 30