Ad
  • Default User Avatar

    Understood. There are other approaches that have linear and even constant run times. Read up on triangular numbers, for example.

  • Default User Avatar

    Yes. It's equivalent to while ( true ) { ... } or do { ... } while ( true );, but without block level scoping. When those loops are compiled into machine code, they're reduced to an unconditional jump instruction, i.e. goto.

    Why are you trying to avoid a nested loop anyway?

    FYI, when you post code to discourse, bracket it with block code formatting so it's easier to read.

  • Custom User Avatar

    Did you forget to include using System; statement?

  • Custom User Avatar

    Not an issue. Your code is causing this.