[Question]
  [
## Introduction
Partly inspired by [this StackOverflow question](https://stackoverflow.com/questions/30640309/how-to-create-a-lightning-bolt-design-using-css), let's draw an ASCII Lightning Bolt.
Write a program that takes a positive Integer `n` via STDIN or command line and outputs the ASCII Lightning Bolt below.
**Input**
Positive Integer `n` representing the number of lightning zig-zag tiers to draw.
**Example Output**
n=1
```
__
\ \
 \ \
  \ \
   \/
```
n=2
```
__
\ \
 \ \
__\ \
\  __\
 \ \
  \ \
   \/
```
n=3
```
__
\ \
 \ \
__\ \
\  __\
 \ \
__\ \
\  __\
 \ \
  \ \
   \/
```
n=4
```
__
\ \
 \ \
__\ \
\  __\
 \ \
__\ \
\  __\
 \ \
__\ \
\  __\
 \ \
  \ \
   \/
```
.
.
.
etc
---
**Additional notes**
* You may write a function that takes `n` as the only argument and
prints or returns the string.
* Trailing spaces and new lines are okay.
* No leading spaces except where appropriate for the designated
pattern.
* **Shortest code in bytes wins.**
  
[Answer]
# Java, ~~201~~ ~~196~~ ~~189~~ ~~186~~ 182 bytes
Obviously not the best, but it *is* in Java.
```
class I{public static void main(String[]a){System.out.print(("__\na a"+new String(new byte[new Byte(a[0])-1]).replace("\0","__a\\  __\\\n a")+"  a   \\/").replace("a","\\ \\\n"));}}
```
[Answer]
# CJam, 41 bytes
```
":¬°√∂ cQ√ØO[nu√∑&,"255b6b"
 _\/X"f='X/~ri(*\
```
I can probably squeeze a few more bytes out, but here's some compression. I picked a base which would lead to no unprintables.
[Try it online](http://cjam.aditsu.net/#code=%22%3A%C2%A1%C3%B6%20cQ%C3%AFO%5Bnu%C3%B7%26%2C%22255b6b%22%0A%20_%5C%2FX%22f%3D'X%2F~ri%28*%5C&input=2).
The lightning bolt is split into `top + middle * (input-1) + bottom`, where `top`, `middle`, `bottom` (compressed using base conversion) are
```
__
\. 
  \
.\.\
__\.\
\..__ 
    \
.\.\
..\.\
...\/
```
*(Spaces are marked with `.`s)*
## 40 bytes
Thanks to [Optimizer](https://codegolf.stackexchange.com/users/31414/optimizer)
```
"¬π√ë¬≥√õ-+√éDx^√°√ê"254b6b"
_\ 0/"f=)/~ri(*\
```
[Answer]
# JavaScript (*ES6*) 76
Using template string, the 3 newlines are significant and counted.
Test running the snippet (Firefox only)
```
f=n=>`__
1 1${`__1\\  __\\
 1`.repeat(n-1)}  1   \\/`.replace(/1/g,`\\ \\
`)
// TEST
go=_=>O.innerHTML=f(I.value)
go()
```
```
N: <input id=I value=3><button onclick='go()'>Test</button>
<pre id=O></pre>
```
[Answer]
## PowerShell, 72 63 bytes
Stupid Windows and your \r\n... This could have been 67 59 bytes!
```
%{$a="\ \
";"__
$a"+" $a`__$a\  __\
"*($_-1)+" $a  $a   \/"}
```
[Answer]
# PHP - ~~84 79~~ 78 bytes
```
<?php
define('N',3); // <- didnt count these bytes as TS said I could take var N as input
?>
<?="__
\ \
 \ \ ".str_repeat("
__\ \
\  __\
 \ \ ",N-1)."
  \ \ 
   \/"
```
View the result source or wrap in `<pre />` to check results. The newlines are required in the code.  
The -1 could be moved to the `define`, but I considered that a cheat.
1st improvement: replace `\n` with actual newlines  
2nd: Since I can define a var, I used a CONTANT, safes the `$`. +an unneeded space in str\_repeat  
3rd: Accidentally removed the -1, but saved a byte by using `<?=` instead of echo. 
[Answer]
# Pyth, 60 54 bytes (Thanks @isaacg)
My first attempt at Pyth, probably very bad.
```
"__
\ \ "VtQ" \ \ 
__\ \ 
\  __\ ")" \ \ 
  \ \ 
   \/
```
[Verify it here](https://pyth.herokuapp.com/?code=%22__%0A%5C+%5C+%22VtQ%22+%5C+%5C+%0A__%5C+%5C+%0A%5C++__%5C+%22)%22+%5C+%5C+%0A++%5C+%5C+%0A+++%5C%2F&input=3&debug=0).
[Answer]
## ><> (Fish), 409 bytes
Run by `fish.py bolt.fish --value n` where `bolt.fish` is the program name and `n` is your positive integer input.
```
\
\         "__"       a
\         "\ \"      a
\         " \ \"     a
\r1-:?!vr "__\ \"    a
\     !0  "\  __\"   a
\     !6  " \ \"  a04.
>r   9a.  "__\ \"    \
      /   "\  __\"  \ 
       /  " \ \"   \  
        / "  \ \" \   
         /"   \/"\    
                 aaaaa
|o|!~r           /    
         \        /   
        \          /  
       \            / 
      \              /
```
It's not short, but it looks cool. My attempt was to try to make it look like a lightning strike. Also, it always errors on completion.
[Answer]
## CJam, 50 bytes
```
"__
\ \
"q~(" \ \
__\ \
\  __\
"*" \ \
"_S\"   \/"
```
[Try it here](http://cjam.aditsu.net/#code=%22__%0A%5C%20%5C%0A%22q~%28%22%20%5C%20%5C%0A__%5C%20%5C%0A%5C%20%20__%5C%0A%22*%22%20%5C%20%5C%0A%22_S%5C%22%20%20%20%5C%2F%22&input=3)
[Answer]
## Brainfuck, 164 bytes
```
,<++++++++++++++++[>--->+>++++++>++>++++++>+++<<<<<<-]>->--->---->>->-<..<<<.>.>
.<.<.>>.<.>.<.<.<[>>>>..<<.>.<.<.>.>..>..<<.<.>>.<.>.<.<.<-]>>>..<.>.<.<.>>...<.
>>>.
```
With comments:
```
Initialise n and character set with i as counter
Memory = in‚ô™\ _/
,<++++++++++++++++[>--->+>++++++>++>++++++>+++<<<<<<-]>->--->---->>->-
Draw top of lightning bolt
<..<<<.>.>.<.<.>>.<.>.<.<.<
Draw lightning bolt zigzags
[>>>>..<<.>.<.<.>.>..>..<<.<.>>.<.>.<.<.<-]
Draw lightning bolt tip
>>>..<.>.<.<.>>...<.>>>.
```
Okay, how this Brainfuck answer beating Java and C#?
[Answer]
# Perl, 69+1
69 characters, plus 1 for the `-n` command line switch to fetch input from stdin.
```
$s="\\ \\$/";print"__$/$s $s".("__$s\\  __\\$/ $s"x--$_)."  $s   \\/"
```
### Usage example:
```
perl -ne '$s="\\ \\$/";print"__$/$s $s".("__$s\\  __\\$/ $s"x--$_)."  $s   \\/"' <<<"2"
__
\ \
 \ \
__\ \
\  __\
 \ \
  \ \
   \/
```
[Answer]
# Javascript (ES6), 86
Not gonna win, but I love 1-line solution and I hate slashes.
```
f=n=>atob("X18KXCBc"+"CiBcIFwKX19cIFwKXCAgX19c".repeat(n-1)+"CiBcIFwKICBcIFwKICAgXC8")
```
[Answer]
# C, 101 bytes
My not so original implementation in c
```
f(n){puts("__\n\\ \\");for(;--n;puts(" \\ \\\n__\\ \\\n\\  __\\"));puts(" \\ \\\n  \\ \\\n   \\/");}
```
[Answer]
# C#, 221 Bytes
```
class C{static void Main(string[]n){int e=System.Int32.Parse(n[0]);var o=@"__{0}\ \{0} \ \{0}";while(e>1){o+=@"__\ \{0}\  __\{0} \ \{0}";e--;}System.Console.WriteLine(o + @"  \ \{0}   \/{0}",System.Environment.NewLine);}}
```
This isn't the best, or the smallest answer, but I figured I'd give it a try.
[Fsacer's answer](https://codegolf.stackexchange.com/questions/51284/draw-an-ascii-lightning-bolt/51322#51322) is much shorter and I think you should check it out.
I just decided to do this just as an alternative method really.
[Answer]
# C#, 166 bytes
```
class I{static void Main(string[]a){System.Console.Write(("__\na a"+"".PadLeft(int.Parse(a[0])-1).Replace(" ",@"__a\  __\
 a")+@"  a   \/").Replace("a",@"\ \
"));}}
```
**EDIT 1:** improved the result from 186B to 173B  
**EDIT 2:** saved 1B by using `PadLeft` instead of `PadRight`  
**EDIT 3:** saved 8B by dropping `PadLeft`'s second parameter and using verbatim string literals 
[Answer]
# Awk, 101+8 bytes
101 characters, plus 8 for `-v n=$1` to get integer from shell.
```
'{l="\\ \\";print"__\n"l"\n "l;for(i=1;i<n;++i)print"__"l"\n\\  __\\\n "l}END{print"  "l"\n   \\/"}'
```
New to this SE site, [unclear](https://codegolf.stackexchange.com/questions/13014/tips-for-golfing-in-awk) if those parameters should count.
### Ungolfed
```
awk 
-v n=$1
'{
  l="\\ \\";
  print "__\n"l"\n "l;
  for(i=1; i<n; ++i)
    print "__"l"\n\\  __\\\n "l
}
END
{
  print "  "l"\n   \\/"
}'
```
### Usage example:
```
lightning() { echo | awk -v n=$1 '{l="\\ \\";print"__\n"l"\n "l;for(i=1;i<n;++i)print"__"l"\n\\  __\\\n "l}END{print"  "l"\n   \\/"}'; }
lightning 3
__
\ \
 \ \
__\ \
\  __\
 \ \
__\ \
\  __\
 \ \
  \ \
   \/
```
[Answer]
# Python 97 82 78char:
```
print(("__\nl l"+"__l\  __\\\n l"*~-input()+"  l   \/").replace('l','\ \\\n'))
```
This is my first code golf 
# @(^\_^)@
Test here
[Answer]
# C, ~~119~~ 108 bytes
```
p(t){for(;t;t/=4)putchar(" \\_\n"[t%4]);}main(c){for(p(13434);p(836),--c;p(57154842));p(265488);puts("/");}
```
# First attempt, 150 bytes
```
v(a){putchar(a);}s(b){b--?v(32),s(b):v(92);}l(b){s(b);s(1);v(10);}main(c){for(puts("__\n\\ \\");l(1),--c;puts("__\\ \\\n\\  __\\"));l(2);s(3);v(47);}
```
`main` is accepting an int argument, so run like this: `./lightning . . .` to pass `4` as argument.
[Answer]
# Python 3, ~~126~~ ~~118~~ 117 bytes
Just something to get us started with.
```
n=int(input())
p=print
p('__\n\\ \\')
for i in[0]*~-n:p(r''' \ \
__\ \
\  __\
''',end='')
p(r''' \ \
  \ \
   \/
''')
```
[Answer]
# Python 2, 76 bytes
```
print'__\n\ \\\n \ \\\n'+r'''__\ \
\  __\
 \ \
'''*~-input()+'  \ \\\n   \/'
```
Just print the first three lines, then print the next three lines `n-1` times, and then print the final 2 lines. All in one go.
And here is a nice try at an alternative that (unfortunately) uses exactly the same number of bytes:
```
print('__\n| |'+'__|\  __\\\n |'*~-input()+'  |   \/').replace('|','\ \\\n')
```
[Answer]
## F#, 98 characters, 105 bytes
```
let l n=(@"__‚ô™‚óô\z"+String.replicate(n-1)@" \z__\z\  __\‚ô™‚óô"+ @" \z  \z   \/").Replace("z"," \\\n")
```
[Answer]
# CJam 54 Chars
not the shortest, but since i started CJam today, im happy with it.
```
rd(:T;{'__}:W~N{'\:XSXN}:V~SV{WVXSSWXNSV;N}T*SSVSSSX'/
```
[Try it](http://cjam.aditsu.net/#code=rd(%3AT%3B%7B'__%7D%3AW~N%7B'%5C%3AXSXN%7D%3AV~SV%7BWVXSSWXNSV%3BN%7DT*SSVSSSX'%2F&input=2)
[Answer]
# Pascal: ~~149~~ ~~142~~ ~~141~~ 137 characters
```
var n:Word;begin
Read(n);Writeln('__'#10'\ \'#10' \ \');for n:=2to n do Writeln('__\ \'#10'\  __\'#10' \ \');Write('  \ \'#10'   \/')end.
```
After all, Pascal's only golfing strength is that backslashes need no escaping‚Ä¶
[Answer]
# Google Sheets, 60 Bytes
Anonymous worksheet function that takes input from range `[A1]` and outputs to the calling cell.
```
="__
\ \
 \ \
"&REPT("__\ \
\  __\
 \ \
",A1-1)&"  \ \
   \/
```
[Answer]
# [Perl 5](https://www.perl.org/), 58 + 1 (`-n`) = 59 bytes
```
say'__
\ \
 \ \ 
'.'__\ \
\  __\
 \ \
'x--$_.'  \ \
   \/'
```
[Try it online!](https://tio.run/##K0gtyjH9/784sVI9Pp4rRiGGSwFIKHCp6wH5IG6MggKQARblUq/Q1VWJ11NXAPMUgJS@@v//Fv/yC0oy8/OK/@v6muoZGBr8180DAA "Perl 5 ‚Äì Try It Online")
[Answer]
# SpecBAS - 135 104 bytes
The apostrophe in PRINT statements moves cursor to a new line.
SpecBAS lets you incorporate ASCII characters in a string via way of `#n`, so have built in some carriage returns (ASCII 13). 
Built a string up using carriage returns and other characters, then used `REP$` to repeat it the required number of times.
```
1 LET b$="\ \": INPUT n: PRINT "__"'b$+REP$(#13" "+b$+#13"__"+b$+#13"\  __\",n-1)'" ";b$'"  ";b$'"   \/"
```
[Answer]
# PHP 155
```
$l=PHP_EOL;echo$l;echo "__$l";for($i=0;$i<$argv[1];$i++){if($i>=1)echo "__\\ \\$l\\  __\\$l";else echo "\\ \\$l";echo " \\ \\$l";}echo "  \\ \\$l   \\/$l";
```
Ungolfed Version
```
$n = $argv[1];
echo PHP_EOL;
echo '__'.PHP_EOL;
for($i=0;$i<$n;$i++)
{
    if($i>=1) {
        echo '__\\ \\'.PHP_EOL.'\\  __\\'.PHP_EOL;
        
    }
    else
    {
        echo '\\ \\'.PHP_EOL;
    }   
    echo ' \\ \\'.PHP_EOL; 
    
        
}    
echo '  \\ \\'.PHP_EOL;
echo '   \\/';
echo PHP_EOL;
```
[Answer]
# Java, ~~183~~ 180 bytes
```
class L{public static void main(String[]a){String b="__\n\\ \\\n \\ \\\n";for(int i=1;i<new Long(a[0]);++i)b+="__\\ \\\n\\  __\\\n \\ \\\n";System.out.print(b+"  \\ \\\n   \\/");}}
```
# Lua, 110 bytes
```
function l(n)print("__\n\\ \\\n \\ \\\n"..string.rep("__\\ \\\n\\  __\\\n \\ \\\n",n-1).."  \\ \\\n   \\/")end
```
[Answer]
# [Retina](https://github.com/mbuettner/retina), 46 bytes
```
.+
__#r r$0x  r   \/
1x
1
__r\  __\# r
r
\ \#   
```
Takes input as unary.
Each line should go to its own file and `#` should be changed to newline in the files. This is impractical but you can run the code as is, as one file, with the `-s` flag, keeping the `#` markers. You can change the `#`'s to newlines in the output for readability if you wish. E.g.:
```
> echo -n 11|retina -s lightning|tr # '\n'
__
\ \
 \ \
__\ \
\  __\
 \ \
  \ \
   \/
```
The algorithm is very simple. The pairs of lines (regex - substitute pairs) do the following substitution steps:
* Surround input with the top and bottom of the lightning.
* Subtract `1` from the unary input.
* Change every unary digit into the middle part of the lightning.
* Decompress the compressed `\ \` parts of the lightning to get the desired output.
[Answer]
# Powershell, 59 bytes
```
'__
\ \'
,' \ \
__\ \
\  __\'*--$args[0]
' \ \
  \ \
   \/'
```
Test script:
```
$f = {
'__
\ \'
,' \ \
__\ \
\  __\'*--$args[0]
' \ \
  \ \
   \/'
}
&$f 1
&$f 2
&$f 3
&$f 4
```
Output:
```
__
\ \
 \ \
  \ \
   \/
__
\ \
 \ \
__\ \
\  __\
 \ \
  \ \
   \/
__
\ \
 \ \
__\ \
\  __\
 \ \
__\ \
\  __\
 \ \
  \ \
   \/
__
\ \
 \ \
__\ \
\  __\
 \ \
__\ \
\  __\
 \ \
__\ \
\  __\
 \ \
  \ \
   \/
```
Explanation:
This script is traditional `top`+`middle`+`bottom`. There is only one smart thing: the comma before the middle string force to repeat an array element rather than a string. Therefore, each `middle` is displayed on a new line.
[Answer]
### x86\_16 machine code - 84 bytes
```
8B CB      MOV CX, BX
49         DEC CX          
B4 09      MOV AH, 09H   
        HEAD:
BA 02 01   MOV DX, OFFSET LIGHTNING_HEAD
CD 21      INT 21H
85 C9      TEST CX, CX   
74 09      JE TAIL
        BODY:
BA 1F 01   MOV DX, OFFSET LIGHTNING_LOOP_STR
CD 21      INT 21H
E3 02      JCXZ TAIL
E2 F7      LOOP BODY     
        TAIL:
BA 12 01   MOV DX, OFFSET LIGHTNING_TAIL
CD 21      INT 21H
B8 00 4C   MOV AX, 4C00H
CD 21      INT 21H       
LIGHTNING_HEAD      DB 05FH, 05FH, 00AH, 00DH, 05CH, 020H, 05CH, 00AH, 00DH, 020H
                    DB 05CH, 020H, 05CH, 00AH, 00DH, 024H
LIGHTNING_TAIL      DB 020H, 020H, 05CH, 020H, 05CH, 00AH, 00DH, 020H, 020H, 020H
                    DB 05CH, 02FH, 024H
LIGHTNING_LOOP_STR  DB 05FH, 05FH, 05CH, 020H, 05CH, 00AH, 00DH, 05CH, 020H, 020H
                    DB 05FH, 05FH, 05CH, 00AH, 00DH, 020H, 05CH, 020H, 05CH, 00AH
                    DB 00DH, 024H
```
Tested using DOSBox
[![enter image description here](https://i.stack.imgur.com/koiTP.png)](https://i.stack.imgur.com/koiTP.png)
[![enter image description here](https://i.stack.imgur.com/Fq7tD.png)](https://i.stack.imgur.com/Fq7tD.png)
[![enter image description here](https://i.stack.imgur.com/CjLnk.png)](https://i.stack.imgur.com/CjLnk.png)
]