Considering that x is the number supplied by the user:
j = 0; //variavel que será responsável pelo indice do vetor
for (int i=2; i<=x; i++) {
vetor[j] = i;
j++;
}
In this way, as the loop is executed, the vector will be organized as follows for x = 4, for example:
vector [0] = 2; vector [1] = 3; vector [2] = 4;