current position:Home>On the test of Fibonacci sequence

On the test of Fibonacci sequence

2022-02-02 20:24:25 CSDN Q & A

part1
public static int[] getFibSeq(int i) {
int[] result = null;
int [] fib= new int [i];
if (i==0) {
result = fib;
}
if (i ==1) {
fib[0]=1;
result = fib;
}
if (i ==2) {
fib[0]=1;
fib[1]=1;
result = fib;
}
else {
for (int j=2 ; j<fib.length; j++) {
if (fib[j-2]+fib[j-1]==fib[j]) {
if (fib[0]==1) {
if(fib[1]==1) {
result=fib;
}

                }            }                            }            }        

.
return result;
}

part2
public void test_isFibSeq_01() {
int[] input = {1, 1};
boolean result = Utilities.isFibSeq(input);
assertEquals(true, result);
}

@Testpublic void test_isFibSeq_02() {    int[] input = {
   
   
   
   2, 2};    boolean result = Utilities.isFibSeq(input);    assertEquals(false, result);}@Testpublic void test_isFibSeq_03() {    int[] input = {
   
   
   
   1, 1, 2, 3, 5, 8, 13};    boolean result = Utilities.isFibSeq(input);    assertEquals(true, result);}@Testpublic void test_isFibSeq_04() {    int[] input = {
   
   
   
   1, 1, 2, 3, 7, 8, 13};    boolean result = Utilities.isFibSeq(input);    assertEquals(false, result);}@Testpublic void test_isFibSeq_05() {    int[] input = {
   
   
   
   2, 2, 4, 6, 10, 16, 26};    boolean result = Utilities.isFibSeq(input);    assertEquals(false, result);} Run... With the code I edited part2  Of Junit test  after test05  There will be errors   I can't figure out how to solve it ,  I hope you can help solve   Thank you for !    



Refer to the answer 1:

Your code is not finished ? Utilities.isFibSeq(input) What is the method ? What's wrong ? What is the error message ? Don't be endless




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202022024235244.html

Random recommended