Skip to content

Instantly share code, notes, and snippets.

@wicksome
Created October 1, 2015 15:40
Show Gist options
  • Save wicksome/ab09b662a40d4dfc1b02 to your computer and use it in GitHub Desktop.
Save wicksome/ab09b662a40d4dfc1b02 to your computer and use it in GitHub Desktop.
피보나치
package kr.opid.recusive;
public class Fibonacci {
public static void main(String[] args) {
System.out.println(fibo(1));
System.out.println(fibo(2));
System.out.println(fibo(3));
System.out.println(fibo(4));
System.out.println(fibo(5));
}
static int fibo(int n) {
if (n == 0) {
return 0;
} else if (n == 1) {
return 1;
} else {
return (fibo(n - 2) + fibo(n - 1));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment