Created
April 29, 2014 22:57
-
-
Save pedronaves/bbd3caee228c1dcf20b1 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 fibonacci; | |
| import javax.swing.JOptionPane; | |
| public class Fibonacci { | |
| public static void main(String[] args) { | |
| int n = Integer.parseInt(JOptionPane.showInputDialog("Digite um valor")); | |
| for (int i = 0; i < 11; i++) { | |
| if(i == 10) { | |
| System.out.print("(" + i + "):" + Sequencia.fibo(i) + "\t"); | |
| } | |
| } | |
| } | |
| } |
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 fibonacci; | |
| public class Sequencia { | |
| static int fibo(int n) { | |
| if (n < 2) { | |
| return n; | |
| } else { | |
| return fibo(n - 1) + fibo(n - 2); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment