Created
March 31, 2014 13:05
-
-
Save stunstunstun/9891854 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Fibo { | |
private static final int MAX_COUNT = 10; | |
private static List<Integer> numbers = new ArrayList<Integer>(); | |
public static void main(String[] args) { | |
// Get | |
for(int i = 0 ; i < MAX_COUNT ; i++) { | |
numbers.add(fibo(i)); | |
} | |
Iterator<Integer> iter = numbers.iterator(); | |
while(iter.hasNext()) { | |
Integer n = (Integer) iter.next(); | |
System.out.println(n); | |
} | |
} | |
private static int fibo(int number) { | |
if(number == 0 || number == 1) | |
return number; | |
return fibo(number - 2) + fibo(number - 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment