Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/main/java/io/zipcoder/Problem2.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
package io.zipcoder;

public class Problem2 {
//I couldn't gert the math right :-(
public String fibonacciIteration(int value) {
int first = 0, next = 1, result = 0;
String toReturn = "0 ";
do {
first = result;
result = first + next;
toReturn += result + " ";
next = result;

} while (result != value);
return toReturn;
}
//Should have gotten started on this one ;-(
public String fibonacciRecursion(int value) {
return null;
}
}

//double prev=0d, next=1d, result=0d;
// for (int i = 0; i < n; i++) {
// result=prev+next;
// prev=next;
// next=result;
// }
// return result;

// int f = 0;
// int g = 1;
//
// for (int i = 1; i <= 10; i++) {
// System.out.print(f + " ");
// f = f + g;
// g = f - g;
// }
14 changes: 14 additions & 0 deletions src/test/java/io/zipcoder/Problem2Test.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
package io.zipcoder;

import org.junit.Assert;
import org.junit.Test;

public class Problem2Test {

Problem2 problem2 = new Problem2();

@Test
public void fibonacciIterationTest(){
String expected = "";

String actual = problem2.fibonacciIteration(15);

Assert.assertEquals(expected, actual);
}
}