# Help me in solving PRIMEPERM problem

### My issue

if n is even then if n/2 is prime then permutation exits other wise in case of evne no permutation exits.
else n is odd if n-2 is prime then permutation exits other wise it does not exits.
in case of odd if n-2 is prime then permutation starts from 3 goes till n and then after that 1 and 2 occurs.

What is wrong in my approach?

### My code

``````
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int t;
cin>>t;
vector<int> v(100000,1);
v=v=0;
for(int j=2;j<100000;j++){
if(v[j]){
for(int i=j*2;i<100000;i+=j) v[i]=0;
}
}
while(t--){
int n,x,y,ans=0,ct=0;
cin>>n;
if(n<4){ cout<<"-1\n";
continue;
}
if(n&1){
if(v[n-2]==0){
cout<<"-1\n";
continue;
}
for(int i=3;i<=n;i++){
cout<<i<<" ";
}
cout<<"1 2";
cout<<endl;
}
else{
if(v[n/2]==0){ cout<<"-1\n";
continue;
}
ct=n/2;
for(int i=ct+1;i<=n;i++){
cout<<i<<" ";
}
for(int i=1;i<=n/2;i++) cout<<i<<" ";
cout<<endl;
}
}

}

``````

Problem Link: PRIMEPERM Problem - CodeChef