Last active
August 24, 2016 19:35
-
-
Save drmcarvalho/f5e58edeb475acdad5a975362cbef233 to your computer and use it in GitHub Desktop.
Serie de fibonacci
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
/** | |
* @author Fael | |
*/ | |
public class Exercicio { | |
public static void main(String[] args) { | |
setVetFib(10); | |
System.out.println("\n"); | |
} | |
static void setVetFib(int n) { | |
int fib, a = 0, b = 1; | |
int vet[] = new int[n]; | |
for (int i = 1; i < n; i++) { | |
fib = a + b; | |
a = b; | |
b = fib; | |
vet[i] = fib; | |
} | |
for (int i = 0; i < n; i++) { | |
System.out.print(" " + vet[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment