View Code of Problem 610

#include <cstdio>
#include <iostream>
using namespace std;
int f(int n){
	if(n==1){
		return 1;
	}else if(n==2){
		return 2;
	}else if(n==3){
		return 5;
	}else{
		return f(n-1)+n-1;
	}
}
int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
			printf("%d\n",f(n));
	}

}


/*
10 5

10 10 5 5 


10 10 5 10 5 5
10 10 10 5 5 5

10 10 10 5 10 5 5 5
10 10 10 5 5 10 5 5
10 10 10 10 5 5 5 5


10 10 10 10 5 10 5 5 5 5 
10 10 10 10 5 5 10 5 5 5 
10 10 10 10 5 5 5 10 5 5
10 10 10 10 10 5 5 5 5 5

*/


Double click to view unformatted code.


Back to problem 610