Created
September 20, 2016 19:53
-
-
Save ericksprengel/73c77ea60aa665b89b8890db08803366 to your computer and use it in GitHub Desktop.
Aula Java - A01E01 - 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
class JavaA01E01Fibonacci { | |
public static void main(String[] args) { | |
// Reference: https://pt.wikipedia.org/wiki/Sequ%C3%AAncia_de_Fibonacci | |
int f0 = 0; | |
int f1 = 1; | |
int aux; | |
System.out.println("0: " + f0); | |
System.out.println("1: " + f1); | |
for(int i = 2; i < 20; i++) { | |
aux = f0; | |
f0 = f1; | |
f1 = f1 + aux; | |
System.out.println(i + ": " + f1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment