[Question]
  [
# *[All credits to Adnan for coming up with this challenge.](http://chat.stackexchange.com/transcript/message/32016426#32016426)*
My last challenge, before [I go on break](http://chat.stackexchange.com/transcript/message/31944993#31944993).
# Task
Given positive integer `n`, if `n` is odd, repeat `/` that many times; if `n` is even, repeat `\` that many times.
(Seriously, the testcases would be much clearer than this description, so just look at the testcases.)
# Specs
* Any reasonable input/output format.
* [Standard loopholes](http://meta.codegolf.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) apply.
# Testcases
```
n output
1 /
2 \\
3 ///
4 \\\\
5 /////
6 \\\\\\
```
  
[Answer]
# Javascript, 22 bytes
```
n=>"\\/"[n%2].repeat(n)
```
Defines an anonymous function.
If only `*` repeated strings in Javascript. *sighs*
[Answer]
## Python, 20 bytes
```
lambda n:'\/'[n%2]*n
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E)/[2sable](https://github.com/Adriandmen/2sable), ~~15~~ ~~11~~ ~~9~~ 8 bytes
```
D√à‚Äû/\s√®√ó
```
*-2 bytes thanks to Leaky Nun*
*-1 byte thanks to Emigna*
[Try it online! in 05AB1E](http://05ab1e.tryitonline.net/#code=RMOI4oCeL1xzw6jDlw&input=NA)  
[or in 2sable](http://2sable.tryitonline.net/#code=RMOI4oCeL1xzw6jDlw&input=NA)
[Answer]
# Perl, 20 bytes
Includes +1 for `-p`
Run with input on STDIN:
```
squigly.pl <<< 6
```
`squigly.pl`
```
#!/usr/bin/perl -p
$_=$_%2x$_;y;01;\\/
```
[Answer]
# J, 10 bytes
```
#'\/'{~2|]
```
This is a six-train verb, consisting of:
```
# ('\/' {~ 2 | ])
```
This is a hook between `#` and `('\/' {~ 2 | ])`; a hook `(f g) y` expands to `y f (g y)`, so this expands to `y # (... y)`, which, for single-characters, yields a list of `y` characters.
The second part is a 5-train, consisting of:
```
'\/' {~ 2 | ]
```
This evaluates to two forks:
```
'\/' {~ (2 | ])
```
The inner fork, `2 | ]`, is modulus two. The outer fork, therefore, is:
```
'\/' {~ mod2
```
Which takes (`{~`) the mod2 index (`mod2`) from the string `/`.
Then, using the hook from above:
```
y # (apt char)
```
This yields what we want, and we are done.
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 21
```
.+
$*/
T`/`\\`^(..)+$
```
[Try it online](http://retina.tryitonline.net/#code=JShHYAouKwokKi8KVGAvYFxcYF4oLi4pKyQ&input=MQoyCjMKNAo1CjY) (First line added to allow multiple testcases to be run).
[Answer]
# C#, 42 bytes
```
string f(int n)=>new string("\\/"[n%2],n);
```
Selects the correct character, then creates a new string consisting of that character repeated `n` times.
[Answer]
# PHP, 38 bytes
```
for(;$i++<$a=$argv[1];)echo'\/'[$a%2];
```
(variant 38 bytes)
```
while($i++<$a=$argv[1])echo'\/'[$a%2];
```
(variant 38 bytes)
```
<?=str_pad('',$a=$argv[1],'\/'[$a%2]);
```
(variant 40 bytes)
```
<?=str_repeat('\/'[($a=$argv[1])%2],$a);
```
[Answer]
# C, 40 bytes
```
i;f(n){for(i=n;i--;)putchar(n%2?47:92);}
```
[Try it on Ideone](https://ideone.com/vf6w78)
[Answer]
# [Jelly](http://github.com/DennisMitchell/jelly), 5 bytes
```
·ªã‚Åæ/\x
```
[Try it online!](http://jelly.tryitonline.net/#code=4buL4oG-L1x4&input=&args=NA) or [Verify all testcases.](http://jelly.tryitonline.net/#code=4buL4oG-L1x4CjZSw4figqw&input=)
```
·ªã‚Åæ/\x
·ªã‚Åæ/\    modular-indexing into the string "/\"
    x   repeat
```
[Answer]
## Haskell, 25 bytes
```
f n=cycle"\\/"!!n<$[1..n]
```
-1 byte thanks to Damien with `cycle`.
[Answer]
# Mathematica, ~~34~~ ~~32~~ 28 bytes
```
If[OddQ@#,"/","\\"]~Table~#&
```
Anonymous function. Takes an integer as input and returns a list of characters as output.
[Answer]
# Mathematica, 29 bytes
```
"\\"["/"][[#~Mod~2]]~Table~#&
```
Cruelly exploits the fact that `[[1]]` returns the first argument of a function while `[[0]]` returns the function (head) itself, applied to the strangely valid function named `"\\"` which is being "evaluated" at `"/"`.
[Answer]
# Powershell, ~~30~~ 27 bytes
Update:
```
param($n)('\','/')[$n%2]*$n
```
Switching to `param`, thanks to [timmyd](https://codegolf.stackexchange.com/users/42963/timmyd).
---
```
"$("\/"[$args[0]%2])"*$args[0]
```
or slightly more readable
```
("\","/")[$args[0]%2]*$args[0]
```
Test:
```
> 1..10 | % { ./run.ps1 $_ }
/
\\
///
\\\\
/////
\\\\\\
///////
\\\\\\\\
/////////
\\\\\\\\\\
```
[Answer]
# Ruby, 15 bytes
```
->n{'\/'[n%2]*n}
```
See it on eval.in: <https://eval.in/632030>
[Answer]
# Fourier, 27 bytes
```
92~SI~N%2{1}{47~S}N(Sai^~i)
```
[**Try it online!**](http://fourier.tryitonline.net/#code=OTJ-U0l-TiUyezF9ezQ3flN9TihTYWlefmkp&input=Ng)
[Answer]
# [Brachylog](http://github.com/JCumin/Brachylog), 15 bytes
```
:2%:"\/"rm:?jbw
```
[Try it online!](http://brachylog.tryitonline.net/#code=OjIlOiJcLyJybTo_amJ3&input=Ng)
### Explanation
```
:2%                Input mod 2‚Ä¶
   :"\/"rm         ‚Ä¶is the index of the element in string "\/",‚Ä¶
          :?j      ‚Ä¶element that we juxtapose Input times to itself‚Ä¶
             bw    ‚Ä¶and print to STDOUT after removing one slash/backslash
```
[Answer]
# [CJam](http://sourceforge.net/projects/cjam/), 9 bytes
```
ri_"\/"=*
```
[Try it online!](http://cjam.tryitonline.net/#code=cmlfIlwvIj0q&input=NQ)
### Explanation
```
ri     e# Read input and convert to integer N.
_      e# Duplicate N.
"\/"=  e# Use N as cyclic index into "\/", giving '\ for even and '/ for odd inputs.
*      e# Repeat N times.
```
[Answer]
# ><> (Fish), 30 Bytes
```
:2%?'/'o1-:?!;30.
30.  >'\'50p
```
First time using this language, but I think I at least saved a little room by conditionally using the / as either part of the output or a mirror to redirect flow. Probably still horribly inefficient though, I feel like it could probably be cut down a little more at the very least.
Input is the initial stack, output is `stdout`
[Try it online!](https://fishlanguage.com/playground/iR7o6DFo3MvNG5dWJ)
[Answer]
# [Dyalog APL](http://goo.gl/9KrKoM), 11 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319)
Requires `‚éïIO‚Üê0` which is default on many systems.
```
‚ä¢‚ç¥'\/'‚äÉ‚ç®2|‚ä¢
```
`‚ä¢` the argument
`‚ç¥` reshapes (repeats)
`'\/'‚äÉ‚ç®` the string "/" selected by
`2|‚ä¢` the division remainder when the argument is divided by two
[TryAPL online!](http://tryapl.org/?a=%u2395IO%u21900%20%u22C4%20f%u2190%u22A2%u2374%27%5C/%27%u2283%u23682%7C%u22A2%20%u22C4%20f%A81%202%203%204%205&run)
[Answer]
# Java 11, ~~68~~ ~~65~~ 29 bytes
```
n->(n%2<1?"\\":"/").repeat(n)
```
-3 bytes saved thanks to *@user902383* and *@SeanBean*  
-36 bytes switching from Java 7 to Java 11+
[Try it online.](https://tio.run/##LY7LDoJADEX3fEUziclMCBjcyUO/QDYuxcUIgylCIcNAYgzfjsNj0Sbtve09lRylVxWfOa9l38NNIv0cACSjdClzBekyAtyNRnpDzq0CJCK7nBzbeiMN5pACQTKTd@F0OMXBlWUZC9mRCV@rTknDSczR4u@GV239@9nYYgGNzeTb/8dTii2vbPUahUkQYZycI3TdXbIw396oxm8H43f2zNTE0WUhMJd8SyhWvAVwqWn@Aw)
**Explanation:**
```
n->                     // Method with integer parameter and String return-type
  (n%2<1?               //  If `n` is even:
         "\\"           //   Use String "\"
        :               //  Else (`n` is odd):
         "/")           //   Use String "/" instead
             .repeat(n) //  Repeat it `n` amount of times
```
[Answer]
# Julia, 20 bytes
```
!x="$("/\\"[x%2])"^x
```
[Answer]
# R, ~~47~~ 46 bytes
```
n=scan();cat(rep(c("\\","/")[n%%2+1],n),sep="")
```
In R, you have to escape backslashes. the argument `sep` also has to be fully specified since it comes after `...`. Thus annoyingly few opportunities to save chars :(
Thanks to bouncyball for golfing away a byte.
[Answer]
# T-SQL 50 bytes
Of course no `STDIN` here, so let's assume a hardcoded `INT` variable like this: `DECLARE @ INT` then the solution is:
```
PRINT IIF(@%2=0,REPLICATE('\',@),REPLICATE('/',@))
```
[Answer]
## [Pip](http://github.com/dloscutoff/pip), 8 bytes
```
"\/"@aXa
```
Straightforward. Uses modular indexing to select the character and string repetition to multiply it. [Try it online!](http://pip.tryitonline.net/#code=IlwvIkBhWGE&input=&args=NQ)
---
This question presents an interesting comparison between Pip, [Pyth](https://codegolf.stackexchange.com/a/91732/16766), and [Jelly](https://codegolf.stackexchange.com/a/91733/16766), the latter two each having scored 5 bytes. All three languages have implicit output, with single-char operators for modular indexing and string repetition, and no requirement to escape backslashes in strings. There are two key differences, though:
1. Under certain circumstances, Pyth and Jelly need only one delimiter to define a string;
2. Pyth and Jelly have syntax such that the input doesn't need to be explicitly represented in the code (though for very different reasons, as [Maltysen explained to me](http://chat.stackexchange.com/transcript/message/32067110#32067110)).
Neither one of these features is likely to show up in Pip1 (I don't like the aesthetics of unbalanced delimiters, and point-free syntax or implicit operands seem like they would be too alien to my infix expression parser), but I'm okay with playing third fiddle. Even though "readability" is extremely relative when golfing, I'd argue that those three extra bytes make the Pip program a lot easier to understand at a glance--and in my book, that's a worthwhile tradeoff.
1 Although, single-character strings in Pip use a single `'` delimiter, inspired by CJam and by quoting in Lisp.
[Answer]
# Psithurism, 11 bytes
```
*(%2?"/:"\)
```
This is a language I'm still developing, but I'm going to start posting answers here to get a feeling of what kind of built-in functions might be useful to have. (This one has taught me I really need some way to index into arrays/strings lol.)
explained:
```
*(        # implicitly multiply the input by
  %2      # implicitly take input mod 2
    ? "/  # / if truthy (1)
    : "\  # \ if falsy (0)
)
```
Curious about Psithurism?  
Github: <https://github.com/AroLeaf/psithurism/>  
Docs (soon‚Ñ¢): <https://psithurism.leaf.moe/>
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 5 bytes
```
*@"\/
```
[Test suite.](http://pyth.herokuapp.com/?code=%2a%40%22%5C%2F&test_suite=1&test_suite_input=1%0A2%0A3%0A4%0A5%0A6&debug=0)
Modular-indexing into the string `\/` and then repeat.
[Answer]
# [Perl 6](http://perl6.org), 16 bytes
```
{<\ />[$_%2]x$_}
```
## Usage:
```
for 1..6 {
  say $_, {<\ />[$_%2]x$_}( $_ )
}
```
```
1/
2\\
3///
4\\\\
5/////
6\\\\\\
```
[Answer]
# SpecBAS - 28 bytes
```
1 INPUT n: ?"\/"(ODD(n)+1)*n
```
`ODD` returns 1 if number is odd, then uses that as an index to print the correct character n number of times. Have to add 1 as SpecBAS strings start at character 1.
[Answer]
# Java 8, 56 bytes
```
(i,j)->{for(j=i;j-->0;)System.out.print(i%2<1?92:'/');};
```
I'd like to thank @Kevin Cruijssen in advanced for golfing my answer further.
# Ungolfed Test Program
```
public static void main(String[] args) {
    BiConsumer<Integer, Integer> consumer = (i, j) -> {
        for (j = i; j-- > 0;) {
            System.out.print(i % 2 < 1 ? 92 : '/');
        }
    };
    consumer.accept(5, 0);
    consumer.accept(1, 0);
    consumer.accept(8, 0);
}
```
]