Skip to content

Instantly share code, notes, and snippets.

@paulopatto
Last active April 29, 2016 18:14
Show Gist options
  • Save paulopatto/09d1f291d631b5414440872209a5eab7 to your computer and use it in GitHub Desktop.
Save paulopatto/09d1f291d631b5414440872209a5eab7 to your computer and use it in GitHub Desktop.
Como escrever código

How written code by ...

public int getFibonacciNumber(int n) {
switch(n) {
case 1: return 1;
case 2: return 1;
case 3: return 2;
case 4: return 3;
case 5: return 5;
case 6: return 8;
case 7: return 13;
default: return -1; // good enough for the demo
}
}
public int fibonacci(int n) {
if (n == 1) {
return 1;
}
else if (n == 2) {
return 2;
}
else {
return fibonacci(n-2) + fibonacci(n-2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment