Skip to main content
2 of 6
added 264 characters in body
Kevin Cruijssen
  • 131.5k
  • 13
  • 144
  • 384

#Java 7, 68 bytes

void c(int i){for(int x=-1;++x<i;)System.out.print(i%2<1?"\\":"/");}

Just like with this answer, the shortest code-golf seems to loop and print. Both recursive and
void c(int i){System.out.print(new String(new char[i]).replace("\0",i%2<1?"\\":"/"));}
seems to be longer.

Ungolfed & test code:

Try it here.

class M{
  static void c(int i){
    for(int x = -1; ++x < i;){
      System.out.print(i % 2 < 1
                        ? "\\"
                        : "/");
    }
  }

  public static void main(String[] a){
    for(int i = 0; i < 10; i++){
      c(i);
      System.out.println();
    }
  }
}

Output:

/
\\
///
\\\\
/////
\\\\\\
///////
\\\\\\\\
/////////
Kevin Cruijssen
  • 131.5k
  • 13
  • 144
  • 384