View Code of Problem 18

#include <iostream>
using namespace std; 
int main(){
	int a[10000]={0};
	a[3]=1;
	a[4]=2;
	int x=3;
	for(int i=5;i<10000;i++){
		a[i]=a[i-1]+x;
		x++;
	}
	int temp;
	while(cin>>temp){
		cout<<a[temp]<<endl;
	}
} 

Double click to view unformatted code.


Back to problem 18