Pattern number pyramid

what is the error in code. my output is wrong#include
using namespace std;

int main(){

int n;
cin>>n;

for(int i= 1; i<=n; i++){
	
	for(int space = 1; space<=n-i; space++){
		cout<<" ";
	}
	
	int val = i;
	for(int cnt = 1; cnt<=i; cnt++){
		cout<<val;
		val = val+i;
	}
	
	val = val - 2;
	for(int cnt = 1; cnt<=i-1; cnt++){
		cout<<val;
		val=val-1;
	}
	
	
	cout<<endl;
}


return 0;

}