From 238cb32c2a0858a116dfa4db568b0654d794cf53 Mon Sep 17 00:00:00 2001 From: donald f Date: Mon, 27 Nov 2017 11:25:46 -0500 Subject: [PATCH] not happy with it --- src/main/java/io/zipcoder/Problem2.java | 34 +++++++++++++++++++++ src/test/java/io/zipcoder/Problem2Test.java | 14 +++++++++ 2 files changed, 48 insertions(+) diff --git a/src/main/java/io/zipcoder/Problem2.java b/src/main/java/io/zipcoder/Problem2.java index e0af6a0..3924bdd 100644 --- a/src/main/java/io/zipcoder/Problem2.java +++ b/src/main/java/io/zipcoder/Problem2.java @@ -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; +// } \ No newline at end of file diff --git a/src/test/java/io/zipcoder/Problem2Test.java b/src/test/java/io/zipcoder/Problem2Test.java index fa9ffa5..92d6919 100644 --- a/src/test/java/io/zipcoder/Problem2Test.java +++ b/src/test/java/io/zipcoder/Problem2Test.java @@ -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); + } }