Skip to content

Instantly share code, notes, and snippets.

@drmcarvalho
Last active August 24, 2016 19:35
Show Gist options
  • Save drmcarvalho/f5e58edeb475acdad5a975362cbef233 to your computer and use it in GitHub Desktop.
Save drmcarvalho/f5e58edeb475acdad5a975362cbef233 to your computer and use it in GitHub Desktop.
Serie de fibonacci
/**
* @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