Skip to content

Instantly share code, notes, and snippets.

@ssd863419
Created May 1, 2014 05:37
Show Gist options
  • Save ssd863419/9d4f78bda30713183743 to your computer and use it in GitHub Desktop.
Save ssd863419/9d4f78bda30713183743 to your computer and use it in GitHub Desktop.
fibonacci
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