fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Collatz
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. System.out.println(getCollatzSequence(-3));
  13. }
  14. public static String getCollatzSequence(int num){
  15. String str = " ";
  16. int counter = 0;
  17. if(num <= 0){
  18. return "Error";
  19. }
  20. while(num != 4){
  21. counter++;
  22. str += num+" ";
  23. if(num % 2 == 0){
  24. num = num / 2;
  25. }
  26. else{
  27. num =(num * 3) - 1;
  28. }
  29. if(counter != 97 && number != 8){
  30. return "Does not converge.";
  31. }
  32. str +="4 2 1";
  33. }
  34.  
  35. }
  36. }
  37. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:37: error: class, interface, or enum expected
}
^
1 error
stdout
Standard output is empty