0

I've been looking at solutions for this problem and saw that most were missing brackets, but I don't think I'm missing any. Any solutions?

Here's my code

public class runningTime{
    public static void main(String[] args) {
        final long start = System.currentTimeMillis();
      for (int i = 1; i <= 100; i ++);
      int k=1;
      int n;
      while (k<n) do {
      int sum = 0;
      int m;
      for (int i = 1; i <= m; i++)
      for (int j = 1; j <= n; j*=2)
      k=k*5; 
        final long end = System.currentTimeMillis();
        System.out.println();
        System.out.println("\n Took: " + ((end - start)) + "ms");
        
      
      }
    }
  }
  
  • 1
    remove `do` keyword – Scary Wombat Sep 29 '22 at 01:02
  • 2
    what code should be included in this loop `for (int j = 1; j <= n; j*=2)` ? wrap with curly braces. As a beginner it is best to wrap all loops with braces whether needed or not – Scary Wombat Sep 29 '22 at 01:03
  • 1
    Are you sure you want that semicolon on the end of the fourth line? Also, it's good to get into the habit of using braces and proper indentation for every single loop, whether you technically need to or not. – Dawood ibn Kareem Sep 29 '22 at 01:09

0 Answers0