Created
July 14, 2014 01:58
-
-
Save alexjlockwood/febcf171605d83e64207 to your computer and use it in GitHub Desktop.
Adjacent Fibonacci #s
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
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