[Question]
  [
This challenge is about printing the abacaba sequence of a specific depth.
Here is a diagram of the first 5 sequences (`a(N)` is the abacaba sequence of depth N, upper/lowercase is just to show the pattern, this is not needed in the output of your program):
```
a(0) = A
a(1) = aBa
a(2) = abaCaba
a(3) = abacabaDabacaba
a(4) = abacabadabacabaEabacabadabacaba
...
a(25) = abacabadabacabaeabacabadabacabafabacabadabacabaeabacabadabacabagabacabadabacabaeabacabadabacabafabacabadabacabaeabacabadabacabahabacabadabacabaeabacabadabacabafabacabadabacabaeabacabadabacabagabacabadabacabaeabacabadabacabafabacabadabacabaeabacabadabacabaiabacabadabacabaeabacabadabacabafabacabadabacabaeabacabadabacabagabacabadabacabaeabacabadabacabafabacabadabacabaeabacabadabacabahabacabadabacabaeabacabadabacabafabacabadabacabaeabacabadabacabagabacabadabacabaeabacabadabacabafabacabadabacabaeabacabadabacabajabacabadabacabaeabacabadabacabafabacabadabacabaeabacabadabacabagabacabadabacabaeabacabadabacabafabacabadabacabaeabacabadabacabahabacabadabacabaeabacabadabacabafabacabadabacabaeabacabadabacabagabacabadabacabaeabacabadabacabafabacabadabacabaeabacabadabacabaia...
```
As you can probably tell, the n'th abacaba sequence is the last one with the n'th letter and itself again added to it. (`a(n) = a(n - 1) + letter(n) + a(n - 1)`)
Your task is to make a program or function that takes an integer and prints the abacaba sequence of that depth. The output has to be correct at least for values up to and including 15.
  
[Answer]
# Pyth, 11 bytes
```
u++GHG<GhQk
```
Simple reduction.
[Answer]
## Python, 44 bytes
```
f=lambda n:"a"[n:]or f(n-1)+chr(97+n)+f(n-1)
```
Looks suspiciously might-be-golfable.
[Answer]
## Haskell, ~~39~~ 37 bytes
```
a 0="a"
a n=a(n-1)++['a'..]!!n:a(n-1)
```
Usage example: `a 3` -> `"abacabadabacaba"`.
Edit: @Angs found two bytes to save. Thanks!
[Answer]
# Pyth, ~~14~~ 13 bytes
Thanks to Jakube for saving a byte!
```
VhQ=+k+@GNk;k
```
A solution with 14 bytes: `VhQ=ks[k@GNk;k`.
Explanation:
```
VhQ=+k+@GNk;k
               # Implicit: k = empty string
VhQ            # For N in range input + 1      
   =           # Assign k
      +@GNk    # Position N at alphabet + k
    +k         # k + above
           ;   # End loop
            k  # Print k
```
Try it [here](https://pyth.herokuapp.com/?code=VhQ%3D%2Bk%2B%40GNk%3Bk&input=3&debug=0)!
[Answer]
# Brainfuck, 157 bytes
```
,+>-[>++<-----]>----->>+<<<<[->>[[->>[>>>]<+<+<[<<<]>>[>>>]<]>>[>>>]<[-<<[<<<]>>[>>>]<+>>[>>>]<]+>+<<<[<<<]>>[>>>]+[>>>]<]<<<+>>[<-<<]<]>>>>[>>>]<<<<<<[<<.<]
```
Input is given in binary.
The basic idea is to repeatedly duplicate the current sequence (starting with "a") and to increment the last element after each iteration:
1. a ‚Üí aa ‚Üí ab
2. ab ‚Üí abab ‚Üí abac
3. abac ‚Üí abacabac ‚Üí abacabac
4. ...
When all of this has been done the specified amount of times, the result gets printed excluding the last element.
## In-depth explanation
The memory is arranged in the following way:
```
.---------.-.-----.----.---.-----.----.---.---
|Countdown|0|Value|Copy|End|Value|Copy|End|...
'---------'-'-----'----'---'-----'----'---'---
            |--Element 1---|--Element 2---|
```
**Countdown** holds the number of copy cycles that are yet to be executed. The ABACABA sequence is stored in adjecent blocks, each made up of 3 cells. **Value** holds the character of the element (i.e. "A","B","C"...). The **Copy** flag indicates whether or not the corresponding element needs to be copied within the current copying cycle (0=copy, 1=don't). The **End** flag is set to 0 for the last element while it is being copied (it's 1 in all other cases).
Now to the actual (slightly ungolfed) program:
```
,                       read Countdown from input
+                       add 1 to avoid off-by-one error
>-[>++<-----]>-----     initialize value cell of first element to 97 ("a")
>>+                     set End flag of first element to 1
<<<<                    move to Countdown
[                       loop until Countdown hits 0 (main loop)
    -                   decrement Countdown
    >>                  move to Value cell of first element
    [                   copying loop
        [               duplication sub-loop
            -           decrement Value cell of the element to copy
            >>          move to End flag
            [>>>]       move to End flag of the last element
            <+<+        increment Copy and Value cell of last element (Copy cell is temporarily abused)
            <           move to End flag of second to last element
            [<<<]>>     move back to Copy cell of first element
            [>>>]<      move to Value cell of the first element where the Copy flag is 0
        ]
        >>[>>>]<        move to (abused) Copy flag of the last element
        [               "copy back" sub-loop
            -           decrement Copy flag
            <<          move to End flag of second to last element
            [<<<]>>     move back to Copy cell of first element
            [>>>]<      move to Value cell of the first element where the Copy flag is 0
            +           increment Value cell
            >>[>>>]<    move back to Copy flag of the last element
        ]
        +>+             set Copy and End flag to 1
        <<<             move to End flag of second to last element
        [<<<]>>         move back to Copy cell of first element
        [>>>]<          move to Value cell of the first element where the Copy flag is 0
        >+<             set Copy flag to 1
        >[>>>]<         move to Value cell of the next element to copy
    ]                   loop ends three cells behind the last "valid" Value cell
    <<<+                increment Value cell of last element
    >>                  move to End flag
    [<-<<]              reset all Copy flag
    <                   move to Countdown
]
>>>>                    move to End flag of first element
[>>>]<<<                move to End flag of last element                
<<<                     skip the last element
[<<.<]                  output Value cells (in reverse order, but that doesn't matter)
```
[Answer]
## [Retina](https://github.com/mbuettner/retina), ~~37~~ 32 bytes
```
$
aa
(T`_l`l`.$
)`1(a.*)
$1$1
z
```
The trailing linefeed is significant. Input is taken [in unary](http://meta.codegolf.stackexchange.com/questions/5343/can-numeric-input-output-be-in-unary).
[Try it online!](http://retina.tryitonline.net/#code=JAphYQooVGBfbGBsYC4kCilgMShhLiopCiQxJDEKego&input=MTExMQ)
[Answer]
# [Haskell](https://www.haskell.org/), 36 bytes
```
tail.(iterate((:"a").succ=<<)"_a"!!)
```
[Try it online!](https://tio.run/##BcHBCoAgDADQX5nSQQ956Rb6J0GMoTUykVy/33rvxHHlWrWkTQW5BseSH5Ts3GrR@jBeohSjtztaY7zeyA0S9IebwAQFFv2oVDyGztT7Dw "Haskell ‚Äì Try It Online")
This uses a different recursive method from most of the other answers. To get the next string in the sequence, we don't join two copies in the previous string with a new letter in between, but instead increment every letter and intersperse `a`'s.
```
aba -> bcb -> abacaba
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 12 bytes (non-competitive)
Code:
```
'aIGDN>.bsJl
```
I'll be damned. I fixed a lot of bugs thanks to this challenge haha.
Explanation:
```
'aIGDN>.bsJl
'a             # Push the character 'a'
  I            # User input
   G           # For N in range(1, input)
    D          # Duplicate the stack
     N         # Push N
      >        # Increment
       .b      # Convert to alphabetic character (1 = A, 2 = B, etc.)
         s     # Swap the last two elements
          J    # push ''.join(stack)
           l   # Convert to lowercase
               # Implicit: print the last item of the stack
```
[Answer]
# JavaScript (ES6), ~~43~~ 42 bytes
```
a=n=>n?a(--n)+(n+11).toString(36)+a(n):"a"
```
*A byte saved thanks to [@Neil](https://codegolf.stackexchange.com/users/17602/neil)!*
Yet another simple recursive solution...
[Answer]
# [jq](https://stedolan.github.io/jq/) `-r`, 43 bytes
```
def f:.-1|[[97]][.+1]//f+[.+98]+f;f|implode
```
[Try it online!](https://tio.run/##yyr8/z8lNU0hzUpP17AmOtrSPDY2Wk/bMFZfP00byLC0iNVOs06rycwtyMlPSf3/34DLkMuIy5jLhMuUy@xffkFJZn5e8X/dIgA "jq ‚Äì Try It Online")
---
With the capitalization pattern from the example outputs, 58 bytes:
```
def f:[[65]][.]//([.-1|f[]%32+96,.+66]|.+.)[:-1];f|implode
```
[Try it online!](https://tio.run/##BcFLDkAwEADQ/ZzCRkKqQ30mwVEms6MJQf2WPbvx3nqpTrNP/MBMnQijlGXGaF30LGlTm54KNEQS0WDOg3Uy@rjs5xamWbUCBzU00EIH9IXzXcLxqL1/ "jq ‚Äì Try It Online")
```
def f:    ...       ;  define a filter named f
      [[65]][.]        base case, if the argument . is 0, return [65]
      //               otherwise
         .-1|f         call the filter recursively
         []%32+96      convert each codepoint to lower case
          ,.+66        append .+66 (. is now the filter argument -1)
         [ ... ]       collect all codepoints in an array
         |.+.          and repeat that array twice
         [:-1]         remove the last integer
f|implode              call the filter on the input and convert the result to a string
```
[Answer]
## CJam (14 bytes)
```
'aqi{'b+1$++}/
```
[Online demo](http://cjam.aditsu.net/#code='aqi%7B'b%2B1%24%2B%2B%7D%2F&input=4)
[Answer]
# Ruby (1.9 and up), 38 bytes
`?a` is a golfier way to write `"a"` but looks weird when mixed with ternary `?:`
```
a=->n{n<1??a:a[n-1]+(97+n).chr+a[n-1]}
```
[Answer]
# [R](https://www.r-project.org/), 48 bytes
```
f=function(n)if(n)paste0(a<-f(n-1),letters[n],a)
```
[Try it online!](https://tio.run/##K/r/P802rTQvuSQzP08jTzMzDUgUJBaXpBpoJNroAnm6hpo6OaklJalFxdF5sTqJmv/TNIw0udI0zDT/AwA "R ‚Äì Try It Online")
Simple recursion.
[Answer]
# [jq](https://stedolan.github.io/jq/), 51 bytes
```
[range(.)+97|[.]|implode]|reduce.[]as$i("a";.+$i+.)
```
[Try it online!](https://tio.run/##yyr8/z@6KDEvPVVDT1Pb0rwmWi@2JjO3ICc/JTW2pig1pTQ5VS86NrFYJVNDKVHJWk9bJVNbT/P/f1MA "jq ‚Äì Try It Online")
My life has improved significantly since I found `reduce` in this language.
-16 bytes from ovs.
[Answer]
# [Labyrinth](https://github.com/m-ender/labyrinth), 31 bytes
```
_-)"(;;
(. ?  {_
@  +}989
   1_
```
[Try it online!](https://tio.run/##y0lMqizKzCvJ@P8/XldTScPamktDT8FeQaE6nstBQUG71tLCkktBQcEw/v9/YwA "Labyrinth ‚Äì Try It Online")
I feel like this can be rearranged to be golfier, but a better layout eludes me. I also have a [cleaner 1-indexed version](https://tio.run/##y0lMqizKzCvJ@P9fwV5bScPamktPW0FJQaE6nkspXkGp1tLckstBQUFT6f9/EwA) which has a higher ratio of walls. This uses [xnor's method](https://codegolf.stackexchange.com/a/193729/76162) of repeatedly incrementing the string and interspersing with `a`s.
[Answer]
# C#, 59 bytes
```
string a(int n){return n<1?"a":a(n-1)+(char)(97+n)+a(n-1);}
```
Just another C# solution...
[Answer]
# Perl, 33 bytes
```
map$\.=chr(97+$_).$\,0..pop;print
```
No real need for un-golfing. Builds the string up by iteratively appending the next character in sequence plus the reverse of the string so far, using the ASCII value of 'a' as its starting point. Uses `$\` to save a few strokes, but that's about as tricky as it gets.
Works for `a(0)` through `a(25)` and even beyond. Although you get into extended ASCII after `a(29)`, you'll run out of memory long before you run out of character codes:
`a(25)` is ~64MiB. `a(29)` is ~1GiB.
To store the result of `a(255)` (untested!), one would need 2^256 - 1 = 1.15x10^77 bytes, or roughly **1.15x10^65 1-terabyte drives.**
[Answer]
# [MATL](https://esolangs.org/wiki/MATL), 14 bytes
```
0i:"t@whh]97+c
```
This uses [version 8.0.0](https://github.com/lmendo/MATL/releases) of the language/compiler, which is earlier than the challenge.
### Example
```
>> matl
 > 0i:"t@whh]97+c
 >
> 3
abacabadabacaba
```
### Explanation
The secuence is created first with numbers `0`, `1`, `2`, ... These are converted to letters `'a'`, `'b'`, `'c'` at the end.
```
0         % initiallize: a(0)
i:        % input "N" and create vector [1, 2, ... N]
"         % for each element of that vector
  t       % duplicate current sequence
  @       % push new value of the sequence
  whh     % build new sequence from two copies of old sequence and new value
]         % end for
97+c      % convert 0, 1, 2, ... to 'a', 'b', 'c'. Implicitly print
```
### Edit
[**Try it online!**](http://matl.tryitonline.net/#code=MGk6InRAd2hoXTk3K2M&input=Mw)
[Answer]
# Java 7, 158 bytes
```
class B{public static void main(String[]a){a('a',Byte.valueOf(a[0]));}static void a(char a,int c){if(c>=0){a(a,c-1);System.out.print((char)(a+c));a(a,c-1);}}}
```
I like to lurk around PPCG and I would enjoy being able to vote/comment on other answers.
Input is given as program parameters. This follows the same format as many other answers here in that it's a straight forward recursive implementation. I would have commented on the other answer but I don't have the rep to comment yet. It's also slightly different in that the recursive call is done twice rather than building a string and passing it along.
[Answer]
# Mathematica, ~~36~~ 32 bytes
```
##<>#&~Fold~Alphabet[][[;;#+1]]&
```
Have you ever watched TWOW 11B?
[Answer]
# [Husk](https://github.com/barbuz/Husk), 12 bytes
```
!¬°S+o·π†:o‚Üí‚ñ≤"a
```
[Try it online!](https://tio.run/##AR0A4v9odXNr//8hwqFTK2/huaA6b@KGkuKWsiJh////NA "Husk ‚Äì Try It Online")
Uses 1-based indexing, which I hope is OK.
## Explanation
```
!             (                                          !!)
 ¬°             iterate(                              )
  S                        <*>
   +                   (++)
    o                         (                     )
     ·π†                         join$   .
      :                             (:)
       o                                    .
        ‚Üí                               succ
         ‚ñ≤                                   maximum
          "a                                          "a"
              (iterate((++)<*>(join$(:).succ.maximum))"a"!!)
```
[Answer]
# Python, ~~62~~ ~~54~~ ~~46~~ 45 bytes
I would like to think that this code can still be golfed down somehow.
Edit: Bug fix thanks to Lynn. -1 byte thanks to squid.
```
a=lambda n:n and a(n-1)+chr(97+n)+a(n-1)or'a'
```
[Try it online!](https://tio.run/##Jcg9CoAwDAbQ3VNka0JxEAdR8DDR@hPQrxK6ePo6@Mb3vOXM6GvV@dJ7SUqYQIpEymg7ievpPA4REv/IHjTUPTsZGcgVx8aDTA09biisbCL1Aw)
[Answer]
# [Vim](https://www.vim.org), 35 bytes
```
:h<_
jjYZZpqqv|yPyl/<c-r>"
xq{Dddl@-@qD
```
[Try it online!](https://tio.run/##K/v/3yrDJp4rKysyKqqgsLCspjKgMkffJlm3yE6Jq6Kw2iUlJcdB16HQ5f9/4/@6ZQA "V (vim) ‚Äì Try It Online")
### Explanation
The buffer starts with a single line containing the input integer.
```
:h<_
jjYZZp
```
[Yank the lowercase alphabet from the help file.](https://codegolf.stackexchange.com/a/97868/16766) Paste it on a new line below the integer, leaving the cursor on the first character of the second line.
```
qq
```
Start recording macro `q`. This will be our "loop."
```
v|y
```
Using visual mode, select everything from the current character to the beginning of the line, inclusive, and yank it. This leaves the cursor on the first character of the line.
```
P
```
Paste the yanked text to the left of the cursor. The cursor is now on the last of the pasted characters.
```
yl
```
Yank that character.
```
/<c-r>"
x
```
Find the next occurrence of the just-yanked character. Delete it.
```
q
```
Stop recording the macro. Conveniently, this first time through the macro has left the alphabet unchanged. The only effect is that the cursor has moved from the `a` to the `b`.
```
{Dddl
```
Go to the beginning of the buffer. Delete the contents of the first line (the input number). Then delete the (now-empty) first line. Move the cursor one character to the right so as to start on `b`.
```
@-@q
```
Execute the macro *N* times, where *N* is the number we just deleted.
```
D
```
Delete the unused remainder of the alphabet.
---
Normally, the `@-@q` idiom is fraught with peril if the number has a chance of being zero, because `0` is not a valid count in Vim; instead, it is treated as a separate command that move the cursor to the beginning of the line. However, in this particular case, an input of `0` is no problem at all:
```
@-
```
Move the cursor to the beginning of the line.
```
@q
```
Execute the macro once. Recall that executing the macro with the cursor on the `a` leaves the alphabet unchanged and the cursor on the `b`.
```
D
```
Delete everything to the end of the line--which leaves only the `a`, exactly the output we want.
[Answer]
# [Knight](https://github.com/knight-lang/knight-lang) (v2.0-alpha), 37 bytes
```
;=q+96=n+1P;=x"";W=n-nT=x++xA-q n xOx
```
[Try it online!](https://knight-lang.netlify.app/v2#WyI7PXErOTY9bisxUDs9eFwiXCI7Vz1uLW5UPXgrK3hBLXEgbiB4T3giLCIzIl0=)
Expanded
```
; = q (+ 96 (= n (+ 1 PROMPT)))
; = x ""
; WHILE (= n (- n TRUE))
    = x (+ (+ x (ASCII (- q n))) x)
: OUTPUT x
```
[Answer]
# [Thunno 2](https://github.com/Thunno/Thunno2) `J`, 9 [bytes](https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md)
```
Oƒóƒ±f2c;‚Å∫√Ñ
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m728JKM0Ly_faGm0kpdS7IKlpSVpuhbr_I9MP7IxzSjZ-lHjrsMtS4qTkouhUgsWmkAYAA)
Port of emanresu A's Vyxal answer.
#### Explanation
```
Oƒóƒ±f2c;‚Å∫√Ñ  # Implicit input
O          # Push 2 ** input
 ƒó         # Push [1..that)
  ƒ±   ;    # Map:
   f       #  Prime factors
    2c     #  Count 2s
       ‚Å∫√Ñ  # Letter of alphabet
           # Implicit output
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 61 [bitsv2](https://github.com/Vyxal/Vyncode/blob/main/README.md), 7.625 bytes
```
¬§$(n√∏A»ÆW‚àë
```
[Try it Online!](https://vyxal.pythonanywhere.com/?v=2#WyI9IiwiIiwiwqQkKG7DuEHIrlfiiJEiLCIiLCI1Il0=)
Uses 1-indexing.
## Explained
Generated using Luminespire
```
¬§$(n√∏A»ÆW‚àë
¬§$         # Push an empty string under the input
  (        # For each n in the range [1, input]:
   n√∏A     #   Get the nth letter of the alphabet
      »Æ    #   Push a copy of the item under the top of the stack. This leaves the stack as [already generated, new letter, already generated]
       W‚àë  #   Wrap and sum the stack
```
[Answer]
# Mathematica, 46 bytes
```
If[#<1,"a",(a=#0[#-1])<>Alphabet[][[#+1]]<>a]&
```
Simple recursive function. Another solution:
```
a@0="a";a@n_:=(b=a[n-1])<>Alphabet[][[n+1]]<>b
```
[Answer]
# K5, 18 bytes
```
"A"{x,y,x}/`c$66+!
```
Repeatedly apply a function to a carried value (`"A"`) and each element of a sequence. The sequence is the alphabetic characters from B up to some number N (``c$66+!`). The function joins the left argument on either side of the right argument (`{x,y,x}`).
In action:
```
 ("A"{x,y,x}/`c$66+!)'!6
("A"
 "ABA"
 "ABACABA"
 "ABACABADABACABA"
 "ABACABADABACABAEABACABADABACABA"
 "ABACABADABACABAEABACABADABACABAFABACABADABACABAEABACABADABACABA")
```
[Answer]
## JavaScript, ~~65~~ 571 bytes
```
n=>eval('s="a";for(i=0;i<n;i++)s+=(i+11).toString(36)+s')
```
Demo:
```
function a(n){
  return eval('s="a";for(i=0;i<n;i++)s+=(i+11).toString(36)+s')
}
alert(a(3))
```
 1 - thanks Neil for saving 8 bytes 
[Answer]
# Japt, ~~20~~ 17 bytes
```
97oU+98 r@X+Yd +X
```
[Test it online!](http://ethproductions.github.io/japt?v=master&code=OTdvVSs5OCByQFgrWWQgK1g=&input=Mw==)
### How it works
```
         // Implicit: U = input integer
65oU+66  // Generate a range from 65 to U+66.
r@       // Reduce each item Y and previous value X in this range with this function:
X+Yd     // return X, plus the character with char code Y,
+X       // plus X.
         // Implicit: output last expression
```
## Non-competing version, 14 bytes
```
97√¥U r@X+Yd +X
```
The `√¥` function is like `o`, but creates the range `[X..X+Y]` instead of `[X..Y)`. [Test it online!](http://ethproductions.github.io/japt?v=master&code=OTf0VSByQFgrWWQgK1g=&input=Mw==)
I much prefer changing the 97 to 94, in which case the output for `5` looks like so:
```
^_^`^_^a^_^`^_^b^_^`^_^a^_^`^_^c^_^`^_^a^_^`^_^b^_^`^_^a^_^`^_^
```
]