Created
October 1, 2015 15:40
-
-
Save wicksome/ab09b662a40d4dfc1b02 to your computer and use it in GitHub Desktop.
피보나치
This file contains hidden or 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
| 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