Skip to content

Instantly share code, notes, and snippets.

@alexjlockwood
Created July 14, 2014 01:58
Show Gist options
  • Save alexjlockwood/febcf171605d83e64207 to your computer and use it in GitHub Desktop.
Save alexjlockwood/febcf171605d83e64207 to your computer and use it in GitHub Desktop.
Adjacent Fibonacci #s
public boolean canMerge(int t1, int t2) {
final int lowFib = Math.min(t1, t2);
final int highFib = Math.max(t1, t2);
int a = 1, b = 1;
while (b < highFib) {
int temp = b;
b = a + b;
a = temp;
}
return a == lowFib && b == highFib;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment