Skip to content

Commit

Permalink
#12 - Update Collatz.java
Browse files Browse the repository at this point in the history
  • Loading branch information
obriensystems authored Dec 29, 2024
1 parent c9b4c25 commit 66830bf
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,13 @@ public void computeRange1bruteForceLong(long aStart, long anEnd) {
maxPath = 1L;
newMax = false;

while (prev > 0) {
while (prev > 1) {
// use low bit modulus
if((prev & 1) == 0) {
prev = prev / 2;
} else {
prev = prev * 3 + 1;
}
}
path++;
if(prev > maxValue) {
maxValue = prev;
Expand Down Expand Up @@ -289,6 +289,7 @@ public void computeRange1bruteForceLong(long aStart, long anEnd) {
System.out.println("Total time: " + (System.currentTimeMillis() - totalStartTime));
}



// 2.02 vs 2.25 growth
// 6400
Expand Down

0 comments on commit 66830bf

Please sign in to comment.