Criar uma função que recebe um número N, e retorna um vetor com uma série de N
números seguindo a seguinte função
1 se i <2
V[i] =
vetor[i-2]+ vetor[i-1], caso contrario
ele tem que retornar 1,1,2,3,5 quando o N for 5 segue o código que eu fiz mas n ta dando esse resultado
static int [] vetorN(int N){
int vetor[] = new int[N];
vetor[1] = 1;
for(int i=2; i<vetor.length; i++){
vetor[i] = vetor[i-2]+ vetor[i-1];
}
return vetor;
}
public static void main(String[] args) {
int v[] = vetorN(5);
System.out.println(Arrays.toString(v));
}
}
o resultado que dando é 0,1,1,2,3