Skip to content

Commit

Permalink
done with Collatz
Browse files Browse the repository at this point in the history
  • Loading branch information
czar committed Oct 26, 2024
1 parent 73b7087 commit 9513607
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lab1/Collatz.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
public class Collatz {

/** Buggy implementation of nextNumber! */

/**
*
* @param n
* @return
*/
public static int nextNumber(int n) {
if (n == 128) {
return 1;
} else if (n == 5) {
return 3 * n + 1;
} else {
return n * 2;
}
if (n % 2 == 0) return n / 2;
else return 3 * n + 1;
}

public static void main(String[] args) {
int n = 5;
System.out.print(n + " ");
Expand Down

0 comments on commit 9513607

Please sign in to comment.