Created
May 1, 2014 05:37
-
-
Save ssd863419/9d4f78bda30713183743 to your computer and use it in GitHub Desktop.
fibonacci
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 Test { | |
public static int fibonacci(int inPut) { | |
int result = 0; | |
if (inPut <= 2) { | |
result = 1; | |
}else{ | |
result += fibonacci(inPut -1 ) + fibonacci(inPut - 2); | |
} | |
return result; | |
} | |
public static void main(String[] args) { | |
for (int i = 1; i < 10; i++) { | |
System.out.print(fibonacci(i) + ","); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment