View Code of Problem 30

#include<stdio.h>
int getSum(int n) {
	if(n==1) return 1;
	return n + getSum(n-1);
}
int main() {
	int n;
	while(scanf("%d", &n)!=EOF) {
		printf("%d\n", getSum(n));
	}
}

Double click to view unformatted code.


Back to problem 30