text:
Make some Alphabet Rain
Alphabet Rain
The Task:
The basic premise is to print out the input string and then repeat each character vertically, based on it's (0-indexed) position in the (case-insensitive) alphabet A-Z. A is at location 0 so is not repeated, e is at position 4 so is repeated 4 times, P is at position 15 so is repeated 15 times, ! is not in A-Z so is repeated 0 times, etc.
For clarity, anything that falls outside of the range B-Zb-z, for example digits or special characters, will not be repeated, and thus will only appear on the first line.
This is code-golf, so shortest solution in each language is the winner.
Input:

Input will be in the standard printable ASCII character set, from 32   up to 126 ~.
The input string will be 1 character long or longer.
There will not be any leading or trailing whitespace.
You can take take input as a string ("hello") or list of characters ( ["h", "e", "l", "l", "o"])

Examples:
Input of aaaa gives:
aaaa

Input of abcda gives:
abcda
 bcd
  cd
   d

Input of Programming Puzzles & Code Golf!, gives:
Programming Puzzles & Code Golf!
Progr mming Puzzles   Code Golf
Progr mming Puzzles   Code Golf
Progr mming Puzzles    ode Golf
Progr mming Puzzles    o e Golf
Progr mming Puzzl s    o   Golf
Progr mming Puzzl s    o   Gol
Pro r mmin  Puzzl s    o    ol
Pro r mmin  Puzzl s    o    ol
Pro r mm n  Puzzl s    o    ol
Pro r mm n  Puzzl s    o    ol
Pro r mm n  Puzzl s    o    ol
Pro r mm n  Puzz  s    o    o
Pro r    n  Puzz  s    o    o
Pro r       Puzz  s    o    o
Pr  r       Puzz  s
 r  r        uzz  s
 r  r        uzz  s
             uzz  s
             uzz
             uzz
              zz
              zz
              zz
              zz
              zz

Input of ~|[abc<0>cba]|~, gives:
~|[abc<0>cba]|~
    bc   cb
     c   c

Notes:

standard loopholes apply
output can be a list of strings, but:
extraneous trailing newlines are not allowed (single \n on final line is acceptable)
output can be a list of lists of characters, so long as it looks like it's raining characters
no leading newline
to our Nordic users who have a few extra letters in their "A-Z" alphabet, feel free to support them, but it's not part of the challenge

Is a single leading \n acceptable?

@Lynn, no leading newlines, the first line should be the input string/character list - I'll update the post!

FWIW, I think they look more like icicles than rain

@cairdcoinheringaahing sounds almost festive

:( Just Nordic?

Just cos I know the Danish alphabet goes a-å rather than a-z, so was just mean as a fun bonus if anyone wanted to tackle it :)

6502 machine code (C64), 113 bytes
00 C0 20 FD AE 20 9E AD 85 FB 20 A3 B6 A0 00 84 FC B1 22 99 6F C1 C9 41 90 14
C9 5B B0 04 E9 40 B0 0E C9 C1 90 08 C9 DB B0 04 E9 C0 B0 02 A9 00 99 6F C0 C5
FC 30 02 85 FC C8 C4 FB D0 D3 A9 00 99 6F C1 A0 C1 A9 6F 20 1E AB A9 0D 20 D2
FF A6 FC D0 01 60 C6 FC A0 00 B9 6F C1 F0 E6 BE 6F C0 D0 07 A9 20 99 6F C1 D0
05 CA 8A 99 6F C0 C8 D0 E7

Online demo
Usage: sys49152,"[string]", e.g. sys49152,"Programming Puzzles & Code Golf!".
Important: If the program was loaded from disk (like in the online demo), issue a new command first! This is necessary because loading a machine program trashes some C64 BASIC pointers.
Note: The C64 is by default in a mode without lowercase letters -- in order to be able to enter a mixed-case string, switch to lowercase mode first by pressing SHIFT+CBM.

Explanation
Here's a commented disassembly listing:
         00 C0       .WORD $C000        ; load address
.C:c000  20 FD AE    JSR $AEFD          ; consume comma
.C:c003  20 9E AD    JSR $AD9E          ; evaluate expression
.C:c006  85 FB       STA $FB            ; store string length
.C:c008  20 A3 B6    JSR $B6A3          ; free string
.C:c00b  A0 00       LDY #$00           ; initialize counter
.C:c00d  84 FC       STY $FC            ; and number of "extra" lines
.C:c00f   .copyloop:
.C:c00f  B1 22       LDA ($22),Y        ; load next character
.C:c011  99 6F C1    STA .outbuf,Y      ; store to buffer
.C:c014  C9 41       CMP #$41           ; compare with 'a'
.C:c016  90 14       BCC .zerocount     ; smaller -> no repetition
.C:c018  C9 5B       CMP #$5B           ; compare with 'z'
.C:c01a  B0 04       BCS .checkupper    ; larger -> check for uppercase
.C:c01c  E9 40       SBC #$40           ; subtract 'a' ('a' - 1 and carry)
.C:c01e  B0 0E       BCS .cl_storecount ; and jump to store in repeat count
.C:c020   .checkupper:
.C:c020  C9 C1       CMP #$C1           ; compare with 'A'
.C:c022  90 08       BCC .zerocount     ; smaller -> no repetition
.C:c024  C9 DB       CMP #$DB           ; compare with 'Z'
.C:c026  B0 04       BCS .zerocount     ; larger -> no repetition
.C:c028  E9 C0       SBC #$C0           ; subtract 'A' ('A' - 1 and carry)
.C:c02a  B0 02       BCS .cl_storecount ; and jump to store in repeat count
.C:c02c   .zerocount:
.C:c02c  A9 00       LDA #$00           ; store 0 ...
.C:c02e   .cl_storecount:
.C:c02e  99 6F C0    STA .repcount,Y    ; ... in repeat count
.C:c031  C5 FC       CMP $FC            ; compare with number of extra lines
.C:c033  30 02       BMI .cl_next       ; smaller -> go on with loop
.C:c035  85 FC       STA $FC            ; repeat count to number of extra lines
.C:c037   .cl_next:
.C:c037  C8          INY                ; next
.C:c038  C4 FB       CPY $FB            ; compare with string length
.C:c03a  D0 D3       BNE .copyloop      ; not yet reached? -> repeat
.C:c03c  A9 00       LDA #$00           ; terminate string in buffer
.C:c03e  99 6F C1    STA .outbuf,Y      ; with 0 byte
.C:c041   .outloop:
.C:c041  A0 C1       LDY #>.outbuf      ; output ...
.C:c043  A9 6F       LDA #<.outbuf      ; ...
.C:c045  20 1E AB    JSR $AB1E          ; ... string
.C:c048  A9 0D       LDA #$0D           ; and output ...
.C:c04a  20 D2 FF    JSR $FFD2          ; ... newline
.C:c04d  A6 FC       LDX $FC            ; load extra line count
.C:c04f  D0 01       BNE .ol_step       ; not zero -> go on
.C:c051  60          RTS                ; WE ARE DONE HERE ;)
.C:c052   .ol_step:
.C:c052  C6 FC       DEC $FC            ; decrease extra line count
.C:c054  A0 00       LDY #$00           ; initialize counter
.C:c056   .eraseloop:
.C:c056  B9 6F C1    LDA .outbuf,Y      ; load next character from buffer
.C:c059  F0 E6       BEQ .outloop       ; 0 byte? -> end of string, output
.C:c05b  BE 6F C0    LDX .repcount,Y    ; load repeat count for this characer
.C:c05e  D0 07       BNE .el_step       ; not 0 yet? -> jump to decrement
.C:c060  A9 20       LDA #$20           ; load code for space
.C:c062  99 6F C1    STA .outbuf,Y      ; store in current string position
.C:c065  D0 05       BNE .el_next       ; and jump to next loop iteration
.C:c067   .el_step:
.C:c067  CA          DEX                ; decrease repeat count ...
.C:c068  8A          TXA                ; ... and ...
.C:c069  99 6F C0    STA .repcount,Y    ; ... store back
.C:c06c   .el_next:
.C:c06c  C8          INY                ; increase counter ...
.C:c06d  D0 E7       BNE .eraseloop     ; and jump back to loop

.C:c06f   .repcount:
.C:c06f              .RES $100          ; 256 bytes for repeat count
.C:c16f   .outbuf:
.C:c16f              .RES $100          ; 256 bytes as buffer for output

c64 machine code. I'm impressed.

@Dschoni thanks, but it's still simple code (and it's fun, for me!) -- you should have a look at the demo scene for really impressive C64 works ;)

If we're gonna keep getting these, we might want to set up links to a JavaScript C64 emulator so people can see them run.

@trlkly I have such a link in my submission, click on "Online demo" ;)

05AB1E, 13 12 bytes
,εDlAsk×}ζ»,

Try it online!
Explanation
,             # print input
 ε      }     # apply to each char in input
  D           # duplicate
   l          # convert to lower case
    Ask       # get index of current char in the lower case alphabet
       ×      # repeat the char that many times
         ζ    # transpose with space as filler
          »,  # join on newlines and print

Need to get index of char in lowercase alphabet? just Ask for it

Pyth, 12 10 9 bytes
.tm+*xGr0

Test suite.
Explanation:
.tm+*xGr0dddQ   Expanded program with autofilled input variable
  m      dddQ    For each character d in the input:
       r0d     get its lowercase variant
     xG        and return its 0-based index in the alphabet
                   (-1 if not found, for special chars)
                (empty string for A/a and special characters)
    *     d    that many of the corresponding character
   +       d   and one more for good measure (because x is 0-indexed)
.t             Transpose it and fill blanks with spaces

12 bytes:
j.t*VmxGr0d

(with trailing newline)
Test suite.
Explanation:
j.t*VmxGr0d
QQ              Expanded program with autofilled input variable
Q               print the input verbatim
     m    dQ    For each character d in the input:
        r0      get its lowercase variant
      xG        and return its 0-based index in the alphabet
                    (-1 if not found, for special chars)
   *V       Q   multiply the corresponding characters in (the second autofilled input)
                 by their alphabet indices we just calculated
                 (empty string for A/a and special characters)
 .t             Transpose it and fill blanks with spaces
j               Join the result on newlines

output can be a list of lists of characters, so long as it looks like it's raining characters - Hence you don't need j

Ah, you're right! I was keeping it because the 12-byte version was printing one line verbatim and I couldn't mix the formats like that, and I forgot I could remove that now that everything is in the transpose. Thanks!

Python 3, 83 bytes
f=lambda s,k=65:[*{*s}-{' '}]and[s]+f([[' ',c][91>ord(c.upper())>k]for c in s],k+1)

Try it online! Takes a list of characters. Returns a list of lists of characters.
Python 2, 90 bytes
f=lambda s,k=65:s.strip()and s+'\n'+f(''.join([' ',c][91>ord(c.upper())>k]for c in s),k+1)

Try it online! Takes a string. Returns a string.

Mathematica, 115 89 bytes
It takes as input a list of characters [{"a", "b", "c", "d", "a"}] and outputs a list of lists of characters
Thread[PadRight[Table[#,Max@Position[Alphabet[]/."a"->#,#|ToLowerCase@#]]&/@#]/. 0->" "]&

Try it online!
-26 bytes from Misha Lavrov
-5 bytes from user202729
but if you want to see the output as it is in the test case, try this (128 bytes) code
Try it online!

For future readers: The part "this answer only works on Mathematica..." is a bit misleading, the problem is Mathematica only support Unicode character in notebook (REPL) mode. In script mode, it only understand ASCII and special characters which have been converted to ASCII (e.g., ∞ (3 bytes) -> \[Infinity] (11 bytes)).

@user202729 ok,I'll edit and address people to read your comment.thanks

Golf suggestion for Mathematica (script mode): \[Infinity] (11 bytes) can be replaced by Infinity (8 bytes) or \:221e (6 bytes). The last one is the default representation of special characters without names. (although it is not the main part)

We can avoid Infinity entirely. The problematic part is If[(d=Min@Position[Alphabet[],If[UpperCaseQ@#,ToLowerCase@#,#]])==∞,1,d] and we can change this to Max@Position[Alphabet[]/."a"->#,#|ToLowerCase@#]. (Searching in the list {#,b,c,d,...,y,z}, we're guaranteed to find # at least once.)

@MishaLavrov very nice. fixed it!

Dyalog APL, 27 22 bytes
5 bytes saved thanks to @Adám
⍉∘↑⊢⍴¨⍨1⌈27|⎕A⍳819⌶⍨∘1

Try it online!
How?
⍴¨⍨ - shape each char to length of
    1⌈ - at least one or
    ⎕A⍳819⌶⍨∘1 - index of the char uppercased in alphabet
        27| - modulo 27
↑ - flatten to a matrix
⍉ - and transpose

22 bytes: ⍉∘↑⊢⍴¨⍨1⌈27|⎕A⍳819⌶⍨∘1

@Adám thanks!  updated

Charcoal, 12 bytes
θ↙↓Ｅ⮌θ×ι⌕α↥ι

Try it online!
-3 thanks to Neil.

Bash, 78, 76 71 bytes
for c in {B..a};{ [[ -n ${1// } ]]&&echo "$1";set "${1//[!$c-Z${c,}-z]/ }";}

Depending on collation (default LC_ALL) can save some more bytes
for c in {b..z} _;{ [[ -n ${1// } ]]&&echo "$1";set "${1//[!$c-Z]/ }";}

Try It Online

Python 2, 111 106 99 98 97 87 93 bytes
s=input()
i=65
while s.strip():print s;s=''.join([' ',c][91>ord(c.upper())>i]for c in s);i+=1

Try it online!

whilecan be replaced with exec to save few bytes, ican start with 65 to save more one to reach 87 bytes

The OP says extraneous trailing newlines are not allowed, but your code prints several of them when the input doesn’t contain z or Z.

@Lynn Fixed, I forgot to double-check the execchange...

Python, 105 103 bytes
2 bytes saved thanks to @TFeld
lambda s:'\n'.join(''.join((' '+l)[i<1or 91>ord(l.upper())>i+64]for l in s)for i in range(26)).rstrip()

Try it online!

103 bytes

@TFeld nice catch, thanks!

C# (.NET Core), 162 bytes
s=>{string A="abcdefghijklmnopqrstuvwxyz",r=s;for(int i=-1;++i<s.Max(A.IndexOf);)r+='\n'+string.Concat(s.Select(c=>A.IndexOf(char.ToLower(c))>i?c:' '));return r;}

Try it online!

Welcome to PPCG and nice first answer. You can shorten your code by using a few tricks. Here is a more golfed version of your code: Try it online!.

Thanks for the comments, I assumed my code had to be executable by itself, so I built it upon that assumption! Thanks for the comment and the mentoring.

If you want to find some more tricks on how to golf in C#, take a look at this post, or take a look at existing C# answers. Happy golfing!

Nice answer. Keep going :)

Hi, welcome to PPCG! Great first answer, especially now that it's golfed. +1 from me. Btw, it's currently 180 bytes, not 162. The required import using System.Linq; is unfortunately mandatory to add to the byte-count (or you should change Max to System.Linq.Max and Select to System.Linq.Max, which would be higher than simply using System.Linq; once.) Again welcome, and enjoy your stay. Oh, and I see @IanH. already mentioned Tips for Golfing in C#. Tips for golfing in  might also be interesting to read through.

Perl 5, 43 bytes
41 bytes code + 2 for -nl.
$c=A;print,s/$c|[^a-z]/ /gi,$c++while/\S/

Try it online!

loop for [_0-9] characters, maybe s/["-$c]/ /gi and -l not needed

@NahuelFouilleul Ahh, yes, I was a little too quick on the test cases. They should be added to the OP! :) Thanks! +4 :(

my suggestion doesn't work for any characters between 32 and 126 (non alpha greater than Z)

@NahuelFouilleul Can't find a shorter way that meets all requirements... I'll keep playing...

JavaScript (ES6), 87 78 76 bytes
-9 bytes thanks to @RickHitchcock.
-2 bytes thanks to @Neil.
f=(s,i=10)=>s.trim()&&s+`
`+f(s.replace(/./g,c=>parseInt(c,36)>i?c:" "),i+1)

Takes input as a string and returns with one trailing newline.
Test Cases

f=(s,i=10)=>s.trim()&&s+`
`+f(s.replace(/./g,c=>parseInt(c,36)>i?c:" "),i+1)

;["hello", "Programming Puzzles & Code Golf!", "~|[abc<0>cba]|~", "abcdefg0123456789"]
.forEach(s=>console.log(f(s)));
.as-console-wrapper{max-height:100%!important}

76 bytes (one trailing new line):  f=(s,i=10)=>s.trim()&&s+'newline'+f(s.replace(/./g,c=>parseInt(c,36)-i?c:" "),i+1)

@RickHitchcock That seems to infinite loop for an input string containing numbers: Try it online!. The idea of step-by-step changes to s is really nice, though.

Ahh, good point.  That can be fixed at the cost of 2 bytes: parseInt(c,36)-i>0

@RickHitchcock Can you not use parseInt(c,36)>i instead to save 2 bytes?

@Neil, duh.  Justin:  What Neil said.  : )

@RickHitchcock Updated, thanks guys!

R, 125 123 bytes
Outgolfed by plannapus
for(i in 1:max(p<-pmax(1,match(tolower(S<-el(strsplit(scan(,""),''))),letters),na.rm=T)))cat(ifelse(p<i," ",S),'\n',sep='')

Try it online!
Prints to stdout with a single trailing newline and reads from stdin().
Let's break it down:
S <- el(strsplit(scan,""))            # split the string to characters

m <- match(tolower(S),letters)        # 1-based index in letters (lowercase a-z)
p <- pmax(1,m,na.rm=T)                # parallel max, replaces NA (non-alphabet) or 0 with 1
for(i in 1:max(p)){                   # iterate
 cat(                                 # print
  ifelse(p<1,' ',S),                  # the corresponding letter in S if p>=1, space otherwise
  '\n',sep='')                        # newline, and no spaces between chars
}

Alternate answer, 106 bytes
function(S)for(i in 1:max(p<-pmax(1,match(tolower(S),letters),na.rm=T)))cat(ifelse(p<i,' ',S),'\n',sep='')

Try it online!
Function; prints to stdout but it's basically my response above ported to accept a list of characters rather than splitting the string, so I feel like it's "cheating." Plus, plannapus' approach with regex is quite neat!

Octave / MATLAB, 74 66 bytes
@(s)char(arrayfun(@(c){repmat(c,1,prod(find(upper(c)==65:90)))},s))'

Try it online!

R, 118 114 bytes
function(a)while(grepl("[^ ]",a)){F=F+1;cat(a,"\n");for(j in c("[^a-zA-Z]",letters[F],LETTERS[F]))a=gsub(j," ",a)}

Thanks to @Giuseppe for those 4 bytes off
Try it online!
Short explanation:
function(a)
    while(grepl("[^ ]",a)){ #As long as the string is not just spaces.
        F=F+1 #Increment letter counter (F is FALSE, hence 0 by default)
        cat(a,"\n") #Print string
        for(j in c("[^a-zA-Z]",letters[F],LETTERS[F])) #Get rid of non-letters, and the current letter in lower and upper case
             a=gsub(j," ",a)
    }

ohhh, wait, potential issue: if a is all spaces, this won't print out anything...but you can change the while condition to grepl()|!F which is still a byte shorter than your original answer.

Bash + sed, 37
sed -rne"/^ *$/q;p;s/\W|"{a..z}/\ /gi

Try it online.

it looks like it's repeating characters in the alphabet 1-too-many times

@streetster I think its fixed now.

PHP, 69 78 77 85+1 bytes
for($c=A;!$c[1]&&~trim($s=&$argn);$s=eregi_replace("[^".++$c."-Z]"," ",$s))echo"$s
";

requires PHP<7. Run as pipe with -nR or try it online.

@Shaggy thanks for pointing out. It´s complete now.

+1 for $c=A;!$c[1];$c++. Nice one! Sadly extraneous trailing newlines are not allowed (single \n on final line is acceptable). So it fails for all strings not containing z.

@Christoph fixed

Japt, 15 14 11 10 bytes
First chance to play with Japt's new string padding methods so there might still be room for improvement.
y_ùZInZu c

Try it

Explanation
Implicit input of string U.
y_

Pass each column of U through a function, where Z is the current element (or letter, in this case).
InZu c

Convert Z to uppercase (u), get its charcode (c) and subtract (u) 64 (I).
ùZ

Pad the start of Z with itself until it reaches that length.

Alternative
y_ùZ9aZn36

Try it

But couldn't you change ùZ to p to save a b...never mind, that's really clever...

@ETHproductions: I made a few attempts with p (there might be 1 in the edit history) but ù won out in the end.

Haskell, 137 136 127 119 bytes
import Data.Char
p c=last$0:[k|k<-[0..25],k+65==ord(toUpper c)]
f s=[[last$c:[' '|i>p c]|c<-s]|i<-[0..maximum$map p s]]

Try it online!
Pretty long but I can't think of any way to shorten it further. I feel like there must be some way shorter than the if-then syntax but I don't see it.
EDIT: Thanks @streetster for helping me shave off one byte! I didn't use toUpper at first because of the cost of importing Data.Char but I forgot that it also provides ord which is much shorter than fromEnum
EDIT 2: Thanks to @Laikoni for shaving off another 6 bytes and identifying a bug which I have now fixed. I used 26 instead of 25 because I forgot that Haskell arrays are inclusive. Then I noticed I could use last instead of head which would allow me to use 0: rather than ++[0].
EDIT 3: Thanks again Laikoni for those 8 bytes. I had actually forgotten about that space. For some reason Sublime Text flips out without it and I  forgot to remove it. I wasn't aware that lists of lines were allowed, I should've read the rules more carefully.

Can you lowercase the input to avoid having to check A-Z as well as a-z and then mod'ing?

@streetster In haskell the toLower and toUpper functions require importing Data.Char which costs more chars than it saves. TIO

You may want to have a look at the tips for golfing in Haskell. E.g. if i>p c then ' ' else c can be shortened to last$c:[' '|i>p c].

Two more things: There is an unnecessary space in [k |  and returning a list of lines is allowed, so you don't need the unlines. Finally, you might be interested in our Haskell chat room.

Excel VBA, 110 Bytes
Anonymous VBE Immediate Window Function that takes input as expected type Variant\String from range [A1] and uses it to make it rain the alphabet in the VBE immediate window.
?[A1]:For i=1To 26:For j=1To[Len(A1)]:c=Mid([A1],j,1):d=Asc(UCase(c)):?IIf((d>64+i)*(d<91),c," ");:Next:?:Next

Sample I/O
[A1]="qwertyuiop[]ASDFGHJKL:'zxcvbnm,./"
?[A1]:For i=1To 26:For j=1To[Len(A1)]:c=Mid([A1],j,1):d=Asc(UCase(c)):?IIf((d>64+i)*(d<91),c," ");:Next:?:Next
qwertyuiop[]ASDFGHJKL:'zxcvbnm,./
qwertyuiop   SDFGHJKL  zxcvbnm
qwertyuiop   SDFGHJKL  zxcv nm
qwertyuiop   SDFGHJKL  zx v nm
qwertyuiop   S FGHJKL  zx v nm
qw rtyuiop   S FGHJKL  zx v nm
qw rtyuiop   S  GHJKL  zx v nm
qw rtyuiop   S   HJKL  zx v nm
qw rtyuiop   S    JKL  zx v nm
qw rtyu op   S    JKL  zx v nm
qw rtyu op   S     KL  zx v nm
qw rtyu op   S      L  zx v nm
qw rtyu op   S         zx v nm
qw rtyu op   S         zx v n
qw rtyu op   S         zx v
qw rtyu  p   S         zx v
qw rtyu      S         zx v
 w rtyu      S         zx v
 w  tyu      S         zx v
 w  tyu                zx v
 w   yu                zx v
 w   y                 zx v
 w   y                 zx
     y                 zx
     y                 z
                       z

Brutal!!! It seams you can also make ?A1:...

@LS_ᴅᴇᴠ, unfortunately, as the [] indicates that the contained string should be evaluated to an object in/on/as a workbook, the [A1] call may not reduced to A1 - as this will not take and print the initial input from the range [A1]; rather this will just leave an empty line and all subsequent lines will be printed

Ups, you're right... Didn't notice this!

Haskell, 98 bytes
p c=sum[length[a..c]|a:e<-["B[","b{"],[c]<e]
f s=[[last$c:[' '|i>p c]|c<-s]|i<-[0..maximum$p<$>s]]

Try it online!
Example usage: f "[Abc]" yields a list of lines: ["[Abc]","  bc ","   c "]. Use putStr.unlines.f $ "[Abc]" for pretty-printed output:
[Abc]
  bc
   c
Partly inspired by Now directly based on user1472751's Haskell answer.

Previous approach (100 99 bytes)
f s=[h|i<-[0..26],h<-[[(c:concat[c<$[a..c]|[a,e]<-["B[","b{"],c<e]++cycle" ")!!i|c<-s]],any(>' ')h]

Try it online!

Oracle SQL, 186 Bytes
Assumes the string will be in a table t in column v:
WITH a(s,l)AS(SELECT v,64 FROM t UNION ALL SELECT REGEXP_REPLACE(s,'[^'||CHR(l+1)||'-Z]',' ',1,0,'i'),l+1 FROM a WHERE l<90)SELECT LISTAGG(RTRIM(s),CHR(10))WITHIN GROUP(ORDER BY l)FROM a

SQL Fiddle
Oracle 11g R2 Schema Setup:
CREATE TABLE t ( v ) AS
SELECT '~|[abc<0>cba]|~' FROM DUAL
/

Query 1:
WITH a(s,l)AS(
  SELECT v,64 FROM t
UNION ALL
  SELECT REGEXP_REPLACE(s,'[^'||CHR(l+1)||'-Z]',' ',1,0,'i'),l+1
  FROM a
  WHERE l<90
)
SELECT LISTAGG(RTRIM(s),CHR(10))WITHIN GROUP(ORDER BY l)
FROM a

Results:
|      LISTAGG(RTRIM(S),CHR(10))WITHINGROUP(ORDERBYL) |
|-----------------------------------------------------|
| ~|[abc<0>cba]|~                                     |
|    abc   cba                                        |
|     bc   cb                                         |
|      c   c                                          |

PowerShell, 122 127 bytes
param($a)$a;(1..25|%{$i=$_;(-join([char[]]$a|%{(' ',$_)[$_-match'[a-z]'-and[math]::Max(0,($_-bor32)-96-$i)]})).TrimEnd()})-ne''

Try it online!
Short thanks to how PowerShell can dynamically cast between [char] and [int], but long because of removing extraneous whitespace and the calculation of whether to output a space or the character.
Bugfix thanks to beatcracker.

Unfortunately, this fails on ~|[abc<0>cba]|~ test case. Try this: param($a)$a;(1..25|%{$i=$_;(-join([char[]]$a|%{(' ',$_)[$_-match'[a-z]'-and[math]::Max(0,($_-bor32)-96-$i)]})).TrimEnd()})-ne''

@beatcracker Good catch. That's a clever way of handling the comparison. Thanks!

Jelly, 15 bytes
ØaḊiÐ€Œl‘⁸ẋ"z⁶Y

Try it online!

Java 8, 151 147 144 143 139 bytes
s->{String x="\n"+s;for(int i=64,t;++i<91;)for(char c:x.toCharArray())s+=(t=c&~32)>64&t<91&t>i|c<11?c:" ";return s.replaceAll("\\s+$","");}

Explanation:
Try it here.
s->{                   // Method with String as both parameter and return-type
  String x="\n"+s;     //  Temp-String (equal to leading new-line + input)
  for(int i=64,        //  Index-integer `i` (starting at 64)
          t;           //  Temp-integer
      ++i<91;)         //  Loop (1) from 'A' (65) to 'Z' (90) (inclusive)
    for(char c:x.toCharArray())
                       //   Inner loop (2) over the character of the array
      s+=(t=c&~32)>64  //    If the current character as uppercase is larger than 'A'
         &t<91         //    and smaller or equal to 'Z'
         &t>i          //    and larger than the current index
         |c<11?        //    or the current character is a new-line
          c            //     Append the current character to `s`
         :             //    Else:
          " ";         //     Append a space to `s` instead
                       //   End of inner loop (2) (implicit / single-line body)
                       //  End of loop (1) (implicit / single-line body)
  return s             //  Return the result,
    .replaceAll("\\s+$","");
                       //   after we've removed all trailing spaces and new-lines
}                      // End of method

Ruby, 70 67 74 bytes
f=->s{puts s;(?b..?z).each{|c|s.gsub! /[^#{c}-z]/i,' ';puts s if s=~/\S/}}

Thanks to @TuukkaX for pointing out some parens could be dropped (-3 bytes)
Unfortunately I then had to add 7 bytes because original version failed to handle "z".
Calling it:
f.call('The quick brown fox jumps over the lazy dog!')
The quick brown fox jumps over the lazy dog!
The quick brown fox jumps over the l zy dog
The quick  rown fox jumps over the l zy dog
The qui k  rown fox jumps over the l zy dog
The qui k  rown fox jumps over the l zy  og
Th  qui k  rown fox jumps ov r th  l zy  og
Th  qui k  rown  ox jumps ov r th  l zy  og
Th  qui k  rown  ox jumps ov r th  l zy  o
T   qui k  rown  ox jumps ov r t   l zy  o
T   qu  k  rown  ox jumps ov r t   l zy  o
T   qu  k  rown  ox  umps ov r t   l zy  o
T   qu     rown  ox  umps ov r t   l zy  o
T   qu     rown  ox  umps ov r t     zy  o
T   qu     rown  ox  u ps ov r t     zy  o
T   qu     row   ox  u ps ov r t     zy  o
T   qu     r w    x  u ps  v r t     zy
T   qu     r w    x  u  s  v r t     zy
T    u     r w    x  u  s  v r t     zy
T    u       w    x  u  s  v   t     zy
T    u       w    x  u     v   t     zy
     u       w    x  u     v         zy
             w    x        v         zy
             w    x                  zy
                  x                  zy
                                     zy
                                     z

The parentheses at the lambda definition can be removed. +1.

C (gcc), 189 bytes
#define F for(q=c,p=s;*p;++p,++q)
char*p,*q,s[99],c[99];main(h){gets(s);F{*q=*p>64&&*p<91?*p-65:*p>96&&*p<123?*p-97:0;h=h>*q?h:*q;}for(puts(s);h--;){F{putchar(*q?--*q,*p:32);}putchar(10);}}

Try it online!

Try puts(""); instead of putchar(10)

178 bytes

q, 42 37 bytes
{(+)max[m]$(m:1+mod[.Q.a?(_)x]26)#'x}

-5 thanks to streetster!

old solution+explanation:
{(+)max[m]$'(m:1+mod[.Q.a?lower x;26])#'x}

{                                        }  / lambda func
                     .Q.a?lower x           / get lowercase of input (ignores non-alpha values) and find (?) their index in "a...z" (.Q.a). non-alpha values return `26`
                 mod[.Q.a?lower x;26]       / get mod 26 of each index, this returns 0 where index is 26
            (m:1+mod[.Q.a?lower x;26])      / add 1 and assign to m
            (m:1+mod[.Q.a?lower x;26])#'x   / m and x conform, so we can take (#) m copies of each (') x at corresponding indices
    max[m]$'(m:1+mod[.Q.a?lower x;26])#'x   / get max of m, and pad each ($') of right-side list to that length
 (+)                                        / transpose the char matrix

{(+)max[m]$(m:1+mod[.Q.a?(_)x]26)#'x} for 37, cant remember how I solved it when creating the question, probably very similar though!

@streetster, thanks! updated. didn't know about k's _ , i typed lower in the q interpreter and got k){$[~t&77h>t:abs@@x;.z.s'x;19<t;.z.s@. x;~t in 10 11h;'`type;_x]}. hence giving my answer in q haha

QBIC, 141 bytes
_L;|dim g(a)┘dim H(a)[a|_SA,b,1|┘H(b)=B┘o=asc(ucase$(B))-65~o<1or o>25|o=0]g(b)=o~g(b)>p|p=g(b)}?A[p|[a|~g(d)|g(d)=g(d)-1\H(d)=@ `]?H(d)';`]?

Wow, this has to be the longest entry I've made using QBIC...
Explanation
_L |                        Assign to num var 'a' the length of
  ;                         A$, which is read off the CMD line
dim g(a)                    Define 'g' as an array of 'a' slots. The lower-
                            case letter denotes it will store numbers.
                            g() will store if we still need to rain down the char at pos ()
                            of the input string.
┘                           Inject a linebreak in the compiled QBasic
dim H(a)                    Define H$ to be an array, also of length 'a', for strings
                            H$(x) will store what to rain down if g(x) > 0
[a|                         Run along the length of the input string
                            (QBasic: FOR b = 1 TO a STEP 1)
  _SA,b,1|┘                 Take a substring at index b on string A$, length 1 and
                            store as B$; lift out each character one at a time
  H(b)=B┘                   Save the character in H$(x)
  o=asc(ucase$(B))-65       Take the ASCII codepoint of that substring, as uppercase
                            minus 65. [A-Z] maps to 0-25. Save that number as 'o'
  ~o<1or o>25               IF o is not in range
  |o=0]                     THEN set o to zero (the same value as 'A/a')
  g(b)=o                    SET the number of rain-down copies to 'o'
  ~g(b)>p                   IF the number of raindowns exceeds the prvious max,
  |p=g(b)                   THEN store the new max into 'p'. This defines the rain-down depth
}                           END IF, NEXT
?A                          PRINT the original, \n
[p|                         FOR c = 1 TO max-depth
  [a|                       FOR d = 1 to LEN(A$)
    ~g(d)                   IF the rain-down counter is positive
    |g(d)=g(d)-1            THEN decrement it by 1
    \H(d)=@ `               ELSE replace the char by a literal space in the char map
    ]                       END IF
    ?H(d)                   PRINT the character at the current pos int he char map
      ';`                   and suppress newlines
  ]                         NEXT character
?                           PRINT \n at the end of the line

I was going to write a QBasic answer until I realized that 26 lines of output wouldn't fit on the screen without scrolling. Does QBIC have the same limitation? If so, what are your thoughts on how that affects the validity of this solution?

@DLosc Same restriction applies to QBIC; it runs QBasic code after all. However, I feel the answer is valid - within the technical possibilities of the QBasic platform. Inputs that don't require displaying 26 lines (like ~|[abc<0>cba]|~) show that the functionality of this is according to spec.

Stacked, 47 bytes
[[:upcase ALPHA\index 0 max#+*]"!LF#`togrid tr]

Try it online! Takes input as list of characters, and returns a list of list of characters.
[[:upcase ALPHA\index 0 max#+*]"!LF#`togrid tr]          input: str
 [                            ]"!                        for(char of str)
   upcase ALPHA\index                                        get index of uppercase char
                                                             in uppercase alphabet
                      0 max                                  max(0, index)
  :                        #+*                               repeat char ^ times
                                 LF#`togrid                  convert to aligned char array
                                            tr               transpose

SOGL V0.12, 12 11 bytes
ā,{Z⁴UW1Χ∙┼

Try it Here!
Explanation:
ā            push an empty array
 ,{          for each character in the input, pushing it
   Z           push the uppercase alphabet
    ⁴          push a duplicate of the character
     U         uppercase it
      W        find its index in that alphabet
       1Χ      get the maximum of that and 1
         ∙     repeat the character that many times
          ┼    append horizontally to that array

Jq 1.5, 106 bytes
foreach("\n","^B-Zb-z",(range(24)|[.+66,.+98]|implode))as$x(.;gsub("[\($x)]";" ");.)|select(.!=length*" ")

Expanded
   foreach ("\n",                            # first pattern won't match anything
            "^B-Zb-z",                       # next a, A and punctuation
            (range(24)|[.+66,.+98]|implode)  # then Bb, Cc, ...
   ) as $x (
     .
   ; gsub("[\($x)]";" ")                     # apply each pattern to input
   ; .
   )
 | select(.!=length*" ")                     # eliminate blank lines

Try it online!

SNOBOL4 (CSNOBOL4), 181 bytes
	S =OUTPUT =INPUT
	U =&UCASE
	L =&LCASE
Z	S NOTANY(U L ' ') =' '	:S(Z)
N	U LEN(1) . X REM . U
	L LEN(1) . Y REM . L
R	S (X | Y) =' '	:S(R)
	S NOTANY(' ')	:F(END)
	OUTPUT =S	:(N)
END

Try it online!
	S =OUTPUT =INPUT		;* read input and print it
	U =&UCASE			;* alias for uppercase letters
	L =&LCASE			;* alias for lowercase letters
Z	S NOTANY(U L ' ') =' '	:S(Z)	;* replace non-alphabet, non-space characters with space
N	U LEN(1) . X REM . U		;* get the Next uppercase letter
	L LEN(1) . Y REM . L		;* get the Next lowercase letter
R	S (X | Y) =' '	:S(R)		;* replace all those with spaces
	S NOTANY(' ')	:F(END)		;* if S is all spaces, terminate the program
	OUTPUT =S	:(N)		;* else print S and goto N
END

Julia 1.0, 97 bytes
f(s,h=c->isletter(c)&&(c-'A')%32)=println.([s;[map(c->h(c)>i ? c : ' ',s) for i=0:maximum(h,s)]])

Try it online!

This only prints one b, 2 c etc, think you need a +1 or something somewhere :)

Change the A to an @ https://tio.run/##DY3dCoMgGEBf5SPIn1GDtrtC13tEF84ZfkObqEH08s7bcw6c7@FQDWcpG0udFbqXmJzJ2USmOSFM93SmvH0@uAgR9@z2O1vStHgVqpO2VhLhBRpGoEC7xGH7RUAxjF6d6A/PbIXryuuhUW/9MXCbSQvhuhpe/g

Should be fixed now

Stax, 12 bytes
î┌→♠─l∙╨"«Pò

Run and debug it

Assembly (MIPS, SPIM), 319 bytes
.text
.globl main
main:
lw $4 4($5)
li $2 4
syscall
li $9 65
li $11 91
li $14 122
move $12 $4
li $2 11
syscall
g:
li $4 10
syscall
addi $9 1
bge $9 $11 n
addi $8 $12 -1
l:
addi $8 1
lb $4 ($8)
beqz $4 g
blt $4 $9 e
blt $4 $11 f
addi $13 $9 32
blt $4 $13 e
bgt $4 $14 e
f:
syscall
j l
e:
li $4 32
j f
n:
li $2 10
syscall

Try it online!
almost positive this can be golfed further, (might be able to use mod instead of a bunch of branches, idk) but i'm not complaining. Takes the string as a command line argument. most of the registers are used for magic ascii numbers, though $9 and $8 update - $9 is the current iteration, starting at 65 (a). $8 starts at the beginning of the string, then iterates over the string until reaching a null terminator. characters that are no longer valid are replaced with '32' or space. Prints a single trailing newline, on the last line.
The output is padded - that is, if the input string is 5 characters long, each printed row will also be 5 characters long, even if this means the last few bytes in a row are space characters.
or more practically: "Faa"=>
"Faa"
 "F  "
 "F  "
 "F  "
 "F  "
 "F  "
The instructions did not specify if we had to trim each row to the shortest possible or if this behavior was allowed. If the trimmed variant is desired I can mark this non-competing.

one cool aside: flipping the contents of e and f in the code will result in [stalagmites](https://tio.run/##RU9BbsIwELzvK7ZShOBQVDsGga89cOULceNYqdZxIaGUfN5du8G9WDOzO7Pj8av3MW4n@zPB1lEwhL7pB0iPBrpjpVCtq90GqMdKooLxMX40RJkfcb/LQAg8ij@kUEgJPnxbJpL9i1OIYnU6a7z5VrSmbXOgAONsAilzWORDjnrlC7ooTEzKWFeHDRh7mRNxYGhKgANswZzULT5Rp1Et/2d1WnQLUUy6ZzvesroU/ESCQT8/U4rHGM/X4K6N9/3g8HybZ7IjrvA9tBZPgbqXXw " - the code will print the line at the top, then grow from the bottom up, as if the text dripped down to the ground and built up over time. Did that by accident first and wondered what I did wrong.

Nice! No requirement to trim the strings so all good on that front :)

PHP 7, 110 Bytes
$t.="
";for($i=66;$i<90&&trim($t);){echo$t;$t=preg_replace('~[^\n'.chr($i).'-Z'.chr(32+$i++).'-z]~', ' ',$t);}

Try it online
Ungolfed
Input given in $t
$t.="
";

for($i=66;$i<90&&trim($t);){
    echo$t;
    $t=preg_replace('~[^\n'.chr($i).'-Z'.chr(32+$i++).'-z]~', ' ',$t);
}

nice answer. Do host it on http://tio.run so people can verify your answer.

@Razetime; Thanks foir the feedback. Done. @Titus: Thanks for showing a simpler alternative to tio.run. :)

Pip, 23 bytes
PaFi,26P{z@?LCa>i?as}Ma

Try it online!
Explanation
PaFi,26P{z@?LCa>i?as}Ma
Pa                      Print the original string
  Fi,26                 loop with variable i across range 0-26
                     Ma Map the input to the following function
        {z@?LCa>i?as}   Replace any symbols with index lesser than i with a space
       P                Print the mapped string

Husk, 15 bytes
T' m?SRȯ-64ca;√

Try it online!
repeat each character, then transpose-pad.

Thunno 2 N, 7 bytes
Ä1|Ḟ×ðƬ

Try it online!
Explanation
Ä1|Ḟ×ðƬ  # Implicit input
Ä        # Get the 1-based index in the alphabet
         # for each character in the input string
 1|      # Replace 0s (non-alphabets) with 1s
   Ḟ×    # Multiply elementwise with the input
     ðƬ  # Transpose with filler space
         # Implicit output, joined on newlines


text:
Multi-Base Primes
For the purpose of this challenge, a multi-base prime is a prime which, when written in base 10, is prime in one or more bases smaller than 10 and larger than 1 as well.  All single-digit primes are trivially multi-base primes.  11 is also a multi-base prime, as 11 in binary is 3, which is prime (it is also prime in base 4 and base 6).  The first few terms are: 2,3,5,7,11,13, 17, 23,31,37,41,43,47,53,61...
Your Task:
Write a program or function that, when given an integer as input, returns/outputs a truthy value if the input is a multi-base prime, and a falsy value if it is not.
Input:
An integer between 1 and 10^12.
Output:
A truthy/falsy valule, depending on whether the input is a multi-base prime.
Test Cases:
3    -> truthy
4    -> falsy
13   -> truthy
2003 -> truthy (Also prime in base 4)
1037 -> falsy (2017 in base 5 but not a prime in base 10)

Scoring:
This is code-golf, lowest score in bytes wins!

Could you add a test case that's prime in base-2 and base-10 only? I haven't been able to find any such numbers yet but if any do exist, I'll need to update my solution.

@Shaggy  173,1259,1277,2069,2099,2237,2797,2801,3331,3539,3541,3851,3929,3989,4261,4349,4373,5077,5087,5279,5399,6047,6269,6389...

Thanks, @StraklSeth. I'd since found a couple but my solution needed to be updated anyway.

Isn't 17 a multi-base prime as well (101 in base 4)?

I concur that 17 seems to be a prime in bases 4, 6, and 10.

The binary evaluation of 19 would be eleven (2^1×1+2^0×9=11), so it seems we are to explicitly ignore evaluating those possibilities that include "excessive digits" - is this correct?

I nominated this question for reopening but I now realize it is unclear.  I would like to see the "excessive digit" problem solved.

Python 2, 159 137 bytes
f=lambda n:p(n)*any(p(b(n,i))for i in range(2,10))
p=lambda n:all(n%x for x in range(2,int(n**0.5)+1))
b=lambda n,i:n and n%i+10*b(n/i,i)

Try it online!
Saved 22 bytes thanks to ovs.

137 bytes

Mathematica, 60 bytes
Or@@(p=PrimeQ)[FromDigits/@IntegerDigits[#,2~Range~9]]&&p@#&

Try it online!

As it stands 19 should be falsey even though 1,9 in "binary" is 1*2+9=11 which is prime. Edit - I've posted a comment under the OP to ask about this.

@JonathanAllan I don't really get you...19 in binary is 10011...

The question poses it the other way around: "11 is also a multi-base prime, as 11 in binary is 3, which is prime"

Japt, 15 14 bytes
j ©Ao2@sX nÃdj

Try it

Explanation
Implicit input of integer U.
j

Test if input is prime (Boo-urns to input validation!).
©

Logical AND (&&).
Ao2@    Ã

Generate an array of integers from 2 to 9 and pass each through a function where X is the current element.
sX n

Convert U to a base-X string (s) and back to an integer (n).
dj

Check if any of the numbers in the array are prime.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Fold up a matrix!
Given a matrix, sum its values up/down or left/right to form an X, fold it up, and return the list. I describe the algorithm here:
Algorithm
Your input will be a odd-sized square matrix of integers within your language's reasonable numerical capacity.
Let's take the following matrix as an example:
1 2 3 2 1
0 3 2 3 0
4 2 5 6 3
7 4 7 9 4
0 6 7 2 5

First, add every number to the closest number that is on the main diagonal or antidiagonal. That is, divide the matrix into four sections along the main diagonal and antidiagonal, and then sum all of the numbers in each section towards the center, like so:
1   2   3   2   1
    ↓   ↓   ↓
0 → 3   2   3 ← 0
        ↓
4 → 2 → 5 ← 6 ← 3
        ↑
7 → 4   7   9 ← 4
    ↑   ↑   ↑
0   6   7   2   5

This step gives the following result:
1        1
  5    5
    39
  17  15
0        5

Then, we fold it by flattening the X and interweaving the elements with the top-left first and the bottom left last. This gives the following result:
1, 0, 5, 17, 39, 5, 15, 1, 5

You can imagine this as stretching the main diagonal and rotating it counterclockwise.
This is the final result.
Challenge
Implement this algorithm. Standard loopholes apply. All reasonable I/O formats acceptable.
Test Cases
Input
Output

1 2 3 2 1
0 3 2 3 0
4 2 5 6 3
7 4 7 9 4
0 6 7 2 5

1, 0, 5, 17, 39, 5, 15, 1, 5

1 2 3 4 5
5 4 3 2 1
1 3 5 7 9
0 9 8 7 6
6 7 8 9 0

1, 6, 11, 16, 47, 7, 22, 5, 0

1 3 7 4 8 5 3
8 4 7 5 3 8 0
0 6 3 6 9 8 4
2 6 5 8 7 4 2
0 6 4 3 2 7 5
0 6 7 8 5 7 4
8 5 3 2 6 7 9

1, 8, 15, 11, 23, 20, 62, 32, 25, 13, 18, 3, 9

Can you add a "not 5×5" matrix test case?

@icrieverytim here you go

TFW when I realize why this won't work: Ծ_Ծ ... ಥ‿ಥ

JavaScript, 113 bytes
s=>(l=s.length-1,a=[],s.map((v,y)=>v.map((n,x)=>a[q=2*[x,y,l-y].sort((u,v)=>u-v)[1]+(y>l/2),q-=q>l]=~~a[q]+n)),a)

f=

s=>(l=s.length-1,a=[],s.map((v,y)=>v.map((n,x)=>a[q=2*[x,y,l-y].sort((u,v)=>u-v)[1]+(y>l/2),q-=q>l]=~~a[q]+n)),a)

<textarea id="i" style="width: 400px; height: 120px">1 2 3 2 1
0 3 2 3 0
4 2 5 6 3
7 4 7 9 4
0 6 7 2 5</textarea>

<button onclick="o.value=f(i.value.trim().split`\n`.map(l=>l.trim().split(/\s+/).map(v => parseInt(v,10)))).join` `">Run</button>

<output id="o"></output>

Umm.. why the ~~? They neutralize each other, so there is no need for them.

@KevinCruijssen ~~undefined==0, so this is golfier than (a[q]||0).

@Neil Ah, hadn't thought about undefined. When I copied the test case tsh used, I noticed it worked without the ~~. And since ~~x is similar -(-x) neutralizing each other, I figured it was somehow put there by accident. Thanks for the correction.

Python, 159 158 bytes
def f(m):l=len(m)-1;r=range(1,l);return m[0][::l]+f([[sum(m[x][1%y*y:(y>l-2)-~y])+m[0][y]*(x<2)+m[l][y]*(x>l-2)for y in r]for x in r])+m[l][::l]if l else m[0]

Try it online!

y+1+(y>l-2) can be (y>l-2)-~y.

Jelly, 25 23 21 bytes
AṂ×ṠṚ
LHŒRṗ2Ç€ḅLĠịFS€

Try it online!
Alternate version, 19 bytes
AṂ×ṠṚ
LHŒRṗ2Ç€ĠịFS€

This didn't use to work because Ġ behaved improperly for nested arrays. The only difference is that the pairs [q, p] mentioned in How it works are sorted lexicographically instead of mapping them to p + nq before sorting.
Try it online!
Background
We start by replacing its elements with coordinates, increasing leftwards and downwards and placing (0, 0) in the center of the matrix.
For a 7x7 matrix M, we get the following coordinates.
(-3,-3) (-3,-2) (-3,-1) (-3, 0) (-3, 1) (-3, 2) (-3, 3)
(-2,-3) (-2,-2) (-2,-1) (-2, 0) (-2, 1) (-2, 2) (-2, 3)
(-1,-3) (-1,-2) (-1,-1) (-1, 0) (-1, 1) (-1, 2) (-1, 3)
( 0,-3) ( 0,-2) ( 0,-1) ( 0, 0) ( 0, 1) ( 0, 2) ( 0, 3)
( 1,-3) ( 1,-2) ( 1,-1) ( 1, 0) ( 1, 1) ( 1, 2) ( 1, 3)
( 2,-3) ( 2,-2) ( 2,-1) ( 2, 0) ( 2, 1) ( 2, 2) ( 2, 3)
( 3,-3) ( 3,-2) ( 3,-1) ( 3, 0) ( 3, 1) ( 3, 2) ( 3, 3)

We now compute the minimum absolute value of each coordinate pair and multiply the signs of both coordinate by it, mapping (i, j) to (sign(i)m, sign(j)m), where m = min(|i|, |j|).
(-3,-3) (-2,-2) (-1,-1) ( 0, 0) (-1, 1) (-2, 2) (-3, 3)
(-2,-2) (-2,-2) (-1,-1) ( 0, 0) (-1, 1) (-2, 2) (-2, 2)
(-1,-1) (-1,-1) (-1,-1) ( 0, 0) (-1, 1) (-1, 1) (-1, 1)
( 0, 0) ( 0, 0) ( 0, 0) ( 0, 0) ( 0, 0) ( 0, 0) ( 0, 0)
( 1,-1) ( 1,-1) ( 1,-1) ( 0, 0) ( 1, 1) ( 1, 1) ( 1, 1)
( 2,-2) ( 2,-2) ( 1,-1) ( 0, 0) ( 1, 1) ( 2, 2) ( 2, 2)
( 3,-3) ( 2,-2) ( 1,-1) ( 0, 0) ( 1, 1) ( 2, 2) ( 3, 3)

Matrix elements that correspond to the same pair have to be summed. To determine the order of the sums, we map each pair (p, q) to p + nq, where n is the number of rows/columns of M.
-24 -16  -8   0   6  12  18
-16 -16  -8   0   6  12  12
 -8  -8  -8   0   6   6   6
  0   0   0   0   0   0   0
 -6  -6  -6   0   8   8   8
-12 -12  -6   0   8  16  16
-18 -12  -6   0   8  16  24

The order of sums corresponds to the order of integers the correspond to its summands.
How it works
LHŒRṗ2Ç€ḅLĠịFS€  Main link. Argument: M (matrix)

L                Compute n, the length (number of rows) of M.
 H               Halve it.
  ŒR             Symmetric range; map t to [-int(t), ..., 0, int(t)].
    ṗ2           Compute the second Cartesian power, yielding all pairs [i, j]
                 with -t ≤ i, j ≤ t.
      Ç€         Map the helper link over the resulting array of pairs.
         L       Yield n.
        ḅ        Unbase; map each pair [q, p] to (p + nq).
          Ġ      Group the indices of the resulting array of n² integers by their
                 corresponding values, ordering the groups by the values.
            F    Flatten M.
           ị     Index into the serialized matrix.
             S€  Compute the sum of each group.

AṂ×ṠṚ            Helper link. Argument: [i, j] (index pair)

A                Absolute value; yield [|i|, |j|].
 Ṃ               Minimum; yield m := min(|i|, |j|).
   Ṡ             Sign; yield [sign(i), sign(j)].
  ×              Multiply; yield [p, q] := [sign(i)m, sign(j)m].
    Ṛ            Reverse; yield [q, p].

this is brilliant.

Dyalog APL, 101 99 64 62 59 bytes
3 bytes saved by @Adám
{+/∘,¨⍵∘×¨d∘=¨k[⍋k←↑∪/,d←∘.((+/1x×××⌊/∘|),)⍨(⍳x)-⌈.5×x←≢⍵]}

Try it online!
Using Dennis' awesome algorithm.

APL (Dyalog), 60 bytes*
In collaboration with my colleague Marshall.
Anonymous prefix lambda. Takes matrix as argument and returns vector. Assumes ⎕IO (Index Origin) to be zero, which is default on many systems.
{(,⍉{+/,(s×-×⍺)↓⍵×i∊¨⍨s←⌊⊃r÷2}⌺r⊢⍵)/⍨,(⊢∨⌽)=/¨i←⍳r←⍴⍵}

Try it online!
{…} anonymous lambda; ⍵ is right argument (as rightmost letter of the Greek alphabet):
 ⍴⍵ shape of the argument (list of two identical elements)
 r← store as r (as in rho)
 ⍳ all ɩndices of an array of that size, i.e. (0 0),(0 1)…
 i← store in i (as in iota)
 =/¨ Boolean where the coordinates are equal (i.e. the diagonal)
 (…) apply this anonymous tacit prefix function:
  ⌽ reverse the argument
  ⊢∨ OR that with the unmodified argument
 , ravel (straighten into simple list)
 We now have a Boolean mask for the diagonals.
 (…)/⍨ use that to filter the following:
  ⊢⍵ yield (to separate from r) the argument
  {…}⌺r call the following anonymous infix lambda on each element, with the r-neighbourhood (padded with zeros as needed) as right argument (⍵), and a two element list of number padded rows,columns (negative for bottom/right, zero for none) as left argument (⍺):
   r÷2 divide r with two
   ⊃ pick the first element (they are identical)
   ⌊ floor it
   s← store as s (for shape)
   i∊⍨¨ for each element of i, Boolean if s is a member thereof
   ⍵× multiply the neighbourhood therewith
   (…)↓ drop the following number of rows and columns (negative for bottom/right):
    ×⍺ signum of the left argument (i.e. the direction of paddings)
    - negate
    s× multiply s therewith
   , ravel (straighten into list)
   +/ sum (plus reduction)
Now we have full matrix of sums, but we need to filter all the values read columnwise.
  ⍉ transpose
  , ravel (straighten into simple list)

* By counting ⌺ as ⎕U233A . Try it online!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Create a pointer sequence
Lets define a pointer sequence to be any sequence such that a(n) = a((n-1)-(a(n-1))) forall n greater than some finite number.  For example if our sequence begun with
3 2 1

Our next term would be 2, because a(n-1) = 1, (n-1)-1 = 1, a(1) = 2 (this example is zero index however it does not matter what index you use the calculation will always be the same.).  If we repeat the process we get the infinite sequence
3 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2

Task
Given some initial array of positive integers output the pointer sequence starting with that array.
Output types
Output is intended to be flexible, if you choose to write a function as your program it can return, either an infinite list of integers or a function that indexes the sequence.  If you choose to write a full program you may output terms of the sequence indefinitely.
You may also choose to take two inputs, the starting array and an index.  If you choose to do this you need only output the term of the sequence at that index.

You will never be given a sequence that requires indexing before the beginning of the sequence.  For example 3 is not a valid input because you would need terms before the 3 to resolve the next term.
This is code-golf so your score will be the number of bytes in your program with a lower score being better.
Test Cases
test cases are truncated for simplicity
2 1   -> 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 ...
2 3 1 -> 2 3 1 3 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 ...
3 3 1 -> 3 3 1 3 3 3 1 3 3 3 1 3 3 3 1 3 3 3 1 3 3 3 1 3 3 3 1 3 ...
4 3 1 -> 4 3 1 3 4 4 3 3 4 4 4 3 4 4 4 4 3 4 4 4 4 3 4 4 4 4 3 4 ...

Is it allowed to output n extra terms in addition to the input array? Or the n-th term starting after those provided as input?

@LuisMendo Sure any indexing is fine.

JavaScript (ES6), 25 bytes
a=>f=n=>a[n]||f(--n-f(n))

An anonymous function that, when called, creates a function f that gives the item at a given index in the sequence.
Please let me know if I misunderstood anything...

You call f(n) from in f(n).  I don't think that will ever terminate, but I don't know JS.

@FunkyComputerMan When n gets low enough the a[n] will return a truthy value, so the || will short-circuit and prevent it from infinitely recursing.

Yeah I got that but n doesn't get any lower with each call.  I'm pretty sure if n is greater than the length of a you will never halt.

@FunkyComputerMan It goes get lower with each call, --n assign n to n-1 so the next reference to it will refer to the decremented n.

@FunkyComputerMan --n decrements n, which means that f(--n-f(n)) is the same as f((n-1)-f(n-1))

Ah I see I didn't realize that integers were mutable.  Makes sense.

They aren't, but --n operates on the variable itself (like n-=1)

That's what mutable is, no? If integers were immutable you wouldn't be able to change them after assignment, that is n=n-1 would throw an error.

@FunkyComputerMan Oh, OK... why did you think they were immutable then?

@FunkyComputerMan huh, in what mainstream language can you not do n=n-1?

@Stephen Any purely declarative language won't let you do that.   Haskell is an example.  I should have remembered that JavaScript allows that but I just didn't realize.

Husk, 7 6 bytes
¡S!o_→

Returns an infinite list.
Try it online!
Note that it takes a while for TIO to truncate and print the result.
Explanation
The operator ¡ has several meanings.
Here I'm using "construct infinite list by iterating a function that computes a new element from the list of existing ones".
Given a list of length N, the new element will have 1-based index N+1.
All we need to do is negate the last element of the list (which is the previous value) and index into the list using the result.
¡S!o_→  Implicit input.
¡       Construct infinite list by iterating this function on input:
 S!      Element at index
    →    last element
  o_     negated.

Haskell, 36 bytes
Takes a list and returns a function that indexes the sequence
l!n|n<length l=l!!n|e<-n-1=l!(e-l!e)

Try it online!
Explanation
Here we are defining a function ! that takes a list l and a index n. If n is less than the length of l we index l by n, otherwise we return l!((n-1)-l!(n-1)).  This follows the recursive definition of the function I gave in the question.
Here is the same program ungolfed.
a l n
 |n<length l = l!!n
 |otherwise = (a l) ((n-1) - (a l) (n-1))

I use e<-n-1 instead of otherwise to save bytes while assigning n-1 to e so it can be used later.

MATL, 13 9 bytes
:"tt0)_)h

Outputs the initial terms followed by n additional terms (allowed by the challenge), where n is a positive integer taken as input.
Try it online!
Explanation
:"      % Implicitly input n. Do the following n times
  tt    %    Duplicate the sequence so far, twice. In the first iteration this
        %    implicitly inputs the array of initial terms
  0)    %    Get value of the last entry, say m
  _)    %    Get value of the entry which is m positions back from the last
  h     %    Append. This extends the array with the new entry
        % Implicit end. Implicitly display

Mathematica, 63 bytes
takes two inputs
(Clear@a;(a@#2[[1]]=#)&~MapIndexed~#;a@n_:=a[n-1-a[n-1]];a@#2)&

Try it online!
-3 bytes from Martin Ender

R, 55 bytes
f=function(a,n)"if"(n<=sum(a|1),a[n],f(a,n-1-f(a,n-1)))

Try it online!
Takes two inputs.

Standard ML (MLton), 58 bytes
fun a$n=if n<length$then List.nth($,n)else a$(n-1-a$(n-1))

Try it online! The function a takes the initial list and an index and returns the sequence element at that index. Example usage: a [4,3,1] 5 yields 4.

Jelly, 6 bytes
NṪịṭµ¡

Takes a sequence S and an integer k, and adds k terms to S.
Try it online!
How it works
NṪịṭµ¡  Main link. Left argument: S (sequence). Right argument: k (integer)

    µ¡  Combine the links to the left into a (variadic) chain and call it k times.
        The new chain started by µ is monadic, so the chain to the left will be
        called monadically.
N           Negate; multiply all elements in S by -1.
 Ṫ          Tail; retrieve the last element, i.e., -a(n-1).
  ị         At-index; retrieve the element of S at index -a(n-1).
            Since indexing is modular and the last element has indices n-1 and 0,
            this computes a( (n-1) - a(n-1) ).
   ṭ        Tack; append the result to S.

Husk, 6 bytes
¡Ṡ!o_→

Try it online!
Figured this out after a lot of frustration with Jo King's help.

Why subtract from the length when you can just index by a negative?

@WheatWizard you mean this? Try it online!

"Figured this out after a lot of frustration with Jo King's help." I'm having a déjà vu moment. You put that sentence in every Husk submission to a challenge of @WheatWizard, do you? xD

no it's generally -1 byte from Jo King @KevinCruijssen

Yeah that was what I had in mind.  Although this now seems suspiciously similar to the existing Husk answer.

@WheatWizard To be fair, I didn't even know there was another husk answer.

@WheatWizard now we have two identical Husk answers!

Python 2, 48 bytes
a=lambda S,n:n<len(S)and S[n]or a(S,~a(S,~-n)+n)

Try it online!

CJam, 10 bytes
{{(_j-j}j}

For CJam, this does very well (It even beats 05ab1e!).
This is an anonymous block that expects input in the form i n on the stack, where i is the index in the sequence and n is an array of starting numbers.
The reason this works so well is because of the j operator, which provides memoized recursion from a set of starting values.
Explanation:
{    Function j(n) with [j(0), j(1), j(2)] = [4, 3, 1], return j(6):
 (    Decrement:    5
 _    Duplicate:    5 5
 j    j(5):
  (    Decrement:   5 4
  _    Duplicate:   5 4 4
  j    j(4):
   (    Decrement:  5 4 3
   _    Duplicate:  5 4 3 3
   j    j(3):
    (    Decrement: 5 4 3 2
    _    Duplicate: 5 4 3 2 2
    j    j(2) = 1:  5 4 3 2 1
    -    Subtract:  5 4 3 1
    j    j(1) = 3:  5 4 3 3
   -    Subtract:   5 4 0
   j    j(0) = 4:   5 4 4
  -    Subtract:    5 0
  j    j(0) = 4:    5 4
 -    Subtract:     1
 j    j(1) = 3:     3
}j   End:           3

Java (8), 60 bytes
int a(int[]a,int n){return n<a.length?a[n]:a(a,--n-a(a,n));}

Takes two inputs (integer-array a and integer n), and outputs the n'th value of the sequence.
Explanation:
Try it here. (Might take a few seconds.)
int a(int[]a,int n){        // Method with int[] and int parameters and int return-type
  return n<a.length?        //  If input `n` is smaller than the length of the array:
          a[n]              //   Output the `n`'th item of the array
         :                  //  Else:
          a(a,--n-a(a,n));  //   Recursive call with `n-1-a(n-1)`
}                           // End of method

05AB1E, 5 bytes
λN<α₅

Outputs the infinite sequence.
Try it online. (No test suite with all test cases at once, because there is a bug when using the recursive environment within an iterator.)
Outputting the \$n^{th}\$ value or first \$n\$ values would cost an additional byte:
Output the (0-based) \$a(n)\$.
Output the first \$n\$ values.
Explanation:
λ      # Start a recursive environment
       # to output the infinite sequence
       # Using the (implicit) input-list I, start the sequence at a(0)=I[0], a(1)=I[1],
       # ..., a(n)=I[n],
       # For which we calculate the next a(n) value as follows:
       #  (implicitly push a(n-1))
 N<    #  Push n-1
   α   #  Calculate the absolute difference between the two: |a(n-1)-(n-1)|
    ₅  #  And use that as n'th value: a(|a(n-1)-(n-1)|)

And I thought using Husk was cheating.

Wolfram Language (Mathematica), 34 31 30 29 bytes
a_f@n_:=a[--t-a@t]&@@a[[t=n]]

Try it online!
Input f[initial...][n], e.g. as f[2, 1][3].
a_f@n_:=                        f[initial...][n], where a=f[initial...]
                     a[[t=n]]   attempt to take an index
        a[--t-a@t]&@@             if out of bounds, recurse

Alternative input formats (also 29 bytes):
f=f[#,--t-#~f~t]&@@#[[t=#2]]&

Try it online!
Input [initial, n], e.g. as f[{2, 1}, 3].
h:f@a_=h[--t-h@t]&@@a[[t=#]]&

Try it online!
Input [initial][n], e.g. as f[{2, 1}][3].

Japt, 8 7 bytes
Outputs the nth term, 0-indexed. Change the second g to h to output the first n terms instead.
ÈgZw}gV

Try it

Nibbles, 4 bytes
.~~_=`($

explanation
.~~      # append until null (aka always in this case)
   _     # first input int list
    =    # array subscript (aka haskell !!)
     `(  # uncons (returning head)
       $ # second value from uncons (the tail)

Note that the $ can't also be implicit due to part of the uncons bin representation using part of its encoding after its arg :(
I say this is non competing because this problem influenced the idea to have the .~~ operator, although something like this was definitely needed and its a standard op in Husk.

I've removed the "non-competing" label, as it's no longer a thing. I'd recommend keeping the disclaimer about the .~~ operator, but otherwise, its fine

Perl, 38 +3 (-anl) bytes
{print;push@F,$_=$F[$#F-$F[$#F]];redo}

Try It Online

Your TIO link goes to a different program.

@Xcali i fixed the link but couldn't execute because could not established a connection with the server.

Java (OpenJDK 8), 95 93 91 90 bytes
a->i->{int j=0,b[]=new int[++i];for(;j<i;j++)b[j]=j<a.length?a[j]:b[~-j-b[j-1]];return b;}

Try it online!

Is not b[(j-1)-...] equivalent to b[~-j-...]?

You can reverse the ternary from j>=a.length to j<a.length to save a byte: j<a.length?a[j]:b[~-j-b[j-1]]. Also I'm curious: why did you go with a loop approach, when the recursive approach that is also explained in the challenge description itself is just 60 bytes?

I do not like to answer with methods and AFAIK a self-referencing Function needs a full program answer

@RobertoGraham No, a recursive method can't be a lambda, so has to be a Java 7 style method. But it's still allowed to just post a (Java 7 style) method instead of the full program.

@KevinCruijssen I've made your answer into a BiFunction, Try it online!. It's possible but you need to post whole program because it references Main

@RobertoGraham Yes, when you make it a lambda using Main or the interface when creating a manual lambda, you will most likely indeed need the full program. But with a Java 7 style method you don't, which is why I stated recursive-methods can be answered in Java 7 style, and all other methods in Java 8 lambda style (or Java 8 lambda with one or more separated Java 7 methods, that's also a third possibility).

05AB1E, 20 bytes
#`r[=ˆŽ¼}[¯¾¯¾è-è=ˆ¼

Expects the input as a space-separated string, keeps outputting indefinitely; pretty straightforward implementation
Example run:
$ 05ab1e -e '#`r[=ˆŽ¼}[¯¾¯¾è-è=ˆ¼' <<< '3 2 1'
3
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
2

Perl 5, -a 30 bytes
#!/usr/bin/perl -a
use 5.10.0
say$F[@F]=$F[-1-$F[-1]]while 1

Try it online!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Nth Ngonal Numbers
Most of us are probably familiar with the concept of triangular and square numbers.  However, there are also pentagonal numbers, hexagonal numbers, septagonal numbers, octagonal numbers, etc.  The Nth Nagonal number is defined as the Nth number of the sequence formed with a polygon of N sides.  Obviously, N >= 3, as there are no 2 or 1 sided closed shapes.  The first few Nth Ngonal numbers are 0, 1, 2, 6, 16, 35, 66, 112, 176, 261, 370, 506, 672, 871....  This is sequence A060354 in the OEIS.
Your Task:
Write a program or function that, when given an integer n as input, outputs/returns the Nth Nagonal number.
Input:
An integer N between 3 and 10^6.
Output:
The Nth Nagonal number where N is the input.
Test Case:
25 -> 6925
35 -> 19670
40 -> 29680

Scoring:
This is code-golf, lowest score in bytes wins!

Related

It would not hurt to add a direct precise definition.

Neim, 1 byte
ℙ

¯\_(ツ)_/¯
Try it online!

A built-in for this?  Really?  Obviously less obscure than I'd thought.

@Gryphon It's existed for ages.

You mean the built-in?

@Gryphon Yeah. It's existed since May.

Weird.  I'd have thought there were a lot of more common sequences to give built-ins to first.

@Gryphon At that point, there were a lot of challenges for polygonal numbers, so I just added a bunch to Neim :P

Got it.  That was before I joined the site, so, ya know, before my time.

This seems to be a built-in for calculating the ath b-gonal number, which gets both its parameters autofilled with the only argument given.

05AB1E, 7 6 bytes
Saved 1 byte thanks to Neil
<ÐP+>;

Try it online!
Explanation
<        # push input-1
 Ð       # triplicate
  P      # product of stack
   +     # add input
    >    # increment
     ;   # divide by 2

<Dn*+>; also works for 7 bytes.

@Neil: Thanks! A modified version of that saved me a byte :)

Can't you do <3m instead of <ÐP?

@EriktheOutgolfer: Sure, but it's the same amount of bytes.

@Emigna Just asked to be sure.

Jelly, 5 bytes
c3×3+

Try it online!
Computes choose(n, 3) × 3 + n.
This translates quite readily to 05AB1E:
05AB1E, 5 bytes
3c3*+

Try it online!

Umm, why do you have a f=\ in a Jelly submission header? :P

PowerShell, 34 28 bytes
param($n)$n*($n*$n-3*$n+4)/2

Try it online!
Closed-form solution golfed from the OEIS page. Used FOIL for another 6 byte savings.

Japt, 9 8 bytes
´U+³ z Ä

Try it

1 byte saved thanks to ETH

Explanation
Decrement (´) the input (U), add the input cubed (³) to that, floor divide by 2 (z) and add 1 (Ä).

There are about a bazillion ways to rewrite this in 9 bytes, but it's tough to find an 8-byte solution... oh, here's one I think should work: ´U+³ z Ä

Nice one, @ETHproductions; got distracted by work while trying to crunch it down.

@ETHproductions Nice one, that's tricky...another one would be ´U+³+2 z.

@EriktheOutgolfer: or ÄÄ instead of +2.

7 bytes: à3 *3+U or U+3*Uà3 (credit goes partly to Lynn)... Quite sure it can be rearranged to save more bytes.

Nice one, @Mr.Xcoder. You should post that yourself, it's different enough to mine.

Pyke, 6 bytes
t3^+he

Try it here!
t      - Decrement.
 3^    - Raise to the power of 3.
   +   - Add the input.
    h  - Increment.
     e - Floor Halve.

Python 2, 23 bytes
lambda n:(~-n)**3-~n>>1

Try it online!

MATL, 7 bytes
t3Xn3*+

Luis Mendo's suggestion, which is a little clearer.
    (implicit input)
t                         duplicate
 3Xn                      n choose 3
    3*                    multiply by 3
      +                   add
(implicit output)

Try it online!
t:3XNn+

Try it online!
Both solutions port Lynn's algorithm
(implicit input)
t                         duplicate
 :                        range (1...n)
  3XN                     push 3, compute all 3-combinations of the range
     n                    number ( equal to 3*choose(n,3) )
      +                   add
(implicit output)

Perhaps a little simpler: t3Xn3*+

huh, I swear I looked for Xn and didn't see it. I'm not convinced I know how to read documentation...

Documentation could be clearer :-) It assumes you more or less know the equivalent Matlab functions. In this case, if you search for combinations of nchoosek in Suever's server it gives both functions as results

Python 2, 25 24 bytes

Saved one byte thanks to Neil; golfed >>1 to /2.

lambda n:n*(n*n-3*n+4)/2

Try it online!

Can you not use /2 instead of >>1?

@Neil True, true.

@Neil It was an artifact from back when there had been a sum that needed division.

Recursiva, 11 bytes
*Ha+-Sa*3a4

Try it online!

JavaScript (ES6), 38 bytes
f=(n,k=n)=>k<2|n<3?k:f(n-1,k)+f(3,k-1)

Recursion FTW (or maybe only for seventh...)

Or you could port the closed form solution for 17 bytes...

Mathematica, 14 bytes
shorter than built-in!!!
(#^2-3#+4)#/2&

Try it online!
and 3 bytes shorter with Martin Ender's help

Cubix, 20 17 bytes
Saved 3 bytes porting Emigna's answer.
Iu(:^\:**p+u@O,2)

Try it online!
    I u
    ( :
^ \ : * * p + u
@ O , 2 ) . . .
    . .
    . .

original answer:
Iu-2^\:*p*qu@O,2+p*:

Try it online!
Expands to the cube
    I u
    - 2
^ \ : * p * q u
@ O , 2 + p * :
    . .
    . .

which implements the (n*(n-2)^2+n^2)/2 approach.

Ohm v2, 3 bytes
DÆ¤

Try it online!

Mathematica, 20 bytes
#~PolygonalNumber~#&

Pyth, 7 bytes
+*3.cQ3

Try it here!
Uses Lynn's algorithm.

dc, 13 bytes
dd2-2^*r2^+2/

A fairly straightforward implementation of the first formula listed on the OEIS page.
# Commands           # Stack Tracker (tm)
# Begin with input   # n
d                    # n n
d                    # n n n
2-                   # n-2 n n
2^                   # (n-2)^2 n n
*                    # n*(n-2)^2 n
r                    # n n*(n-2)^2
2^                   # n^2 n*(n-2)^2
+                    # n*(n-2)^2+n^2
2/                   # (n*(n-2)^2+n^2)/2 # matches first formula
# End with output on stack

Japt, 7 bytes
à3 *3+U

Try it here!
First, it was a comment on Shaggy's answer, but they told me I should post it myself.

Only noticing this now - +1.

05AB1E, 2 bytes
ÅU

Try it online!
How?
¯\_(ツ)_/¯

HOPS, 17 bytes
{n*(n*n-3*n+4)/2}
Attempt This Online!
Using the generating function given on OEIS by R. J. Mathar:
HOPS, 23 bytes
x*(1-2*x+4*x^2)/(1-x)^4
Attempt This Online!
Or using the exponential generating function given on OEIS by Paul Barry:
HOPS, 24 bytes
(exp(x)*(x+x^3/2)).*{n!}
Attempt This Online!
-3 bytes thanks to alephalpha

-3 bytes for the last one: (exp(x)*(x+x^3/2)).*{n!}.

K (ngn/k), 23 bytes
{x*(((x*x)-(3*x))+4)%2}

Try it online!
Having to add parenthesis because K parses from right-to-left.

"Having to add parenthesis because K parses from right-to-left." - you don't have to add all of them

for instance the ( ) around 3*x are unnecessary, and you can avoid more pairs by rewriting things in equivalent ways

Jelly, 6 bytes
’*3+‘H

Try it online!
Uses Emigna's algorithm inspired by Neil.

I think you'll find that the <Dn*+>; comment was mine...

I'm using his modification, but I'll add you as well.

cQuents 0, 16 bytes
#|1:A(AA-3A+4)/2

Try it online!

Java 8, 18 bytes
n->n*(n*n-3*n+4)/2

Try it here.
The approach used by most other answers is the shortest in Java. For funsies I also ported two other answers:
Port of Mr. Xcoder's Python 2 answer (29 bytes):
n->(int)Math.pow(n-1,3)-~n>>1

Try it here.
Port of Lynn's Jelly answer (with manual calculation of a choose b) (76 bytes):
n->c(n,3)*3+nint c(int t,int c){return t<c?0:c==t|c==0?1:c(--t,c-1)+c(t,c);}

Try it here.


text:
Repeat the Nth elements
We haven't had a string question for a while (5 days to be precise), so let's go for one.
Given a string s and a positive integer n, take every nth element of s, repeat it n times, and put it back into s.
For example, if n = 3 and s = "Hello, World!", every third character is Hl r!. You then repeat each character n times to produce HHHlll   rrr!!!. You then replace the original letters with the repeated versions to produce the final product of HHHellllo,   Worrrld!!!
You are to accomplish this task in the shortest code possible in your language!
Rules

This is a code-golf so the shortest code in bytes wins
n is guaranteed to be smaller than the length of s and greater than 0
The first character of s is where the nth characters are taken from, and is always repeated n times
s will only consist of printable ASCII (code points 0x20 (space) to 0x7E (~))

Test cases
s, n => output

"Hello, World!", 3 => "HHHellllo,   Worrrld!!!"
"Code golf", 1 => "Code golf"
"abcdefghijklm", 10 => "aaaaaaaaaabcdefghijkkkkkkkkkklm"
"tesTing", 6 => "ttttttesTingggggg"
"very very very long string for you to really make sure that your program works", 4 => "vvvvery    veryyyy verrrry loooong sssstrinnnng foooor yoooou toooo reaaaally    makeeee surrrre thhhhat yyyyour    proggggram    workkkks"

Can we take the input s as a character array?

"and put it back into s" <- is this a strict requirement (overwriting the original string) or ist it ok to just output the final result?

@KevinCruijssen Yes you can

@FelixPalmen that was simply how I explained it. You can use any method you want

@cairdcoinheringaahing good, thanks, already did that.

Jelly, 3 bytes
Ḣs×

Input is taken as s, n.
Try it online!
How it works
Ḣs×  Main link. Argument: s, n

Ḣ    Head; yield s.
     This pops the list, leaving [n] as the main link's argument.
 s   Split s into chunks of length n.
  ×  Multiply each chunk by [n], repeating its first element n times.

Isn't it actually 6 bytes in UTF-8 encoding? E1 B8 A2 73 C3 97

In UTF-8, yes. However, Jelly uses a custom code page, where each of the characters it understands takes up only a single byte.

Jelly,  6  5 bytes
-1 byte thanks to leaky Nun (use Python's string multiplication.)
×Jm¥¦

A full program, accepting two command line arguments, the string and the number, and printing the result.
Try it online!
How?
×Jm¥¦ - Main link: list of characters, s; number, n   e.g. ['g','o','l','f','e','r'], 2
    ¦ - sparse application:
   ¥  - ...to indices: last two links as a dyad:
 J    -      range of length of s                          [1,2,3,4,5,6]
  m   -      modulo slicing by n (every nth entry)         [1,3,5]
×    - ...action: multiply  ["gg",'o',"ll",'f',"ee",'r']
      - implicit print                                 >>> ggollfeer

5 bytes?

Yep tried x forgot ×; thanks.

Isn't it actually 8 bytes in UTF-8 encoding? C3 97 4A 6D C2 A5 C2 A6

@CoDEmanX Uses Jelly's custom code page

@MDXF thanks for fielding!

JavaScript (ES6), 46 bytes
Takes input in currying syntax (s)(n).
s=>n=>s.replace(/./g,(c,i)=>c.repeat(i%n?1:n))

Test cases

let f =

s=>n=>s.replace(/./g,(c,i)=>c.repeat(i%n?1:n))

console.log(f("Hello, World!")(3))
console.log(f("Code golf")(1))
console.log(f("abcdefghijklm")(10))
console.log(f("tesTing")(6))
console.log(f("very very very long string for you to really make sure that your program works")(4))

C# (.NET Core), 84 82 bytes
n=>m=>{var s="";for(int i=0;i<n.Length;)s+=new string(n[i],i++%m<1?m:1);return s;}

Try it online!

You can save a byte by removing i++ and changing n[i],i%m<1?m:1 to n[i],i++%m<1?m:1.

You can save another byte by currying the inputs: n=>m=>...

05AB1E, 8 7 bytes
-1 byte thanks to @Emigna
ôʒć²×ì?

Try it online!
Explanation
ôʒć²×ì?    Arguments s, n  ("Hello, World!", 3)
ô          Split s into pieces of n  (["Hel", "lo,", ...])
 ʒ         Filter (used as foreach)
  ć          Extract head  ("Hel" -> "el", "H" ...)
   ²×ì       Repeat n times and prepend  ("el", "H" -> "HHHel" ...)
      ?      Print without newline

Save a byte with ôʒć²×ì?

@Emigna thanks, I knew there must be a way to get rid of the closing }

Weird use of filter when it isn't using the result but it actually makes a difference...

@MagicOctopusUrn, yep filter is still the better foreach in 05AB1E

@kalsowerus vy is one foreach, ε is another. Oddly enough, ε doesn't work.

Proton, 44 bytes
s=>n=>"".join(s[i]*(i%n?1:n)for i:0..len(s))

Try it online!

Python 2, 54 53 bytes
Edit: Saved 1 byte thanks to @Rod
f=lambda x,n,i=0:x[i:]and[1,n][i%n<1]*x[i]+f(x,n,i+1)

Try it online!

you can swap x[i] and [1,n][i%n<1] to save a space

Alice, 25 bytes
/
KI /!Iw?&.?t&O?&wWOI.h%

Try it online!
Explanation
/         Switch to Ordinal.
I         Read first line of input (i.e. n).
/         Switch to Cardinal.
!         Convert input to its integer value and store it on the tape.
I         Read first character from input string.
w         Push current IP address onto the return address stack. This
          effectively marks the beginning of the main loop.

  ?         Retrieve n.
  &.        Duplicate current character n times (once more than we need,
            but who cares about a clean stack...).
  ?t        Retrieve n and decrement.
  &O        Output n-1 copies of the current character.
  ?         Retrieve n.
  &w        Push the current IP address onto the return address stack n
            times. This marks the beginning of a loop that is executed n
            times.

    W         Discard one copy of the return address from the stack,
              effectively decrementing the loop counter.
    O         Output the last character. On the first iteration, this is
              the final copy of the repeated character, otherwise it's just
              the single character we read on the last iteration.
    I         Read a character for the next iteration.
    .h%       Compute c % (c+1) on that character, which is a no-op for
              for valid characters, but terminates the program at EOF when
              c becomes -1.

K         Jump to the address on top of the return address stack. As long
          as there are still copies of the address from the inner loop, we
          perform another iteration of that, otherwise we jump back to the
          beginning of the outer loop.

R, 82 76 75 bytes
function(s,n)cat(rep(S<-el(strsplit(s,'')),c(n,rep(1,n-1))+!seq(S)),sep='')

Try it online!
A function; takes a string s and an integer n, and prints the repeated version to stdout.
Explanation:
function(s,n){
 S <- el(strsplit(s,""))                  # characters
 r     <- c(n,rep(1,n-1))                 # [n, 1, 1,...,1], length n
 repeats <- r+!seq(S)                     # extends R to length of S
 cat(rep(S, repeats), sep="")             # print out
}

R, 55 bytes
function(S,n)cat(rep(S,c(n,rep(1,n-1))+!seq(S)),sep="")

Try it online!
Same algorithm as above, but with S taken as a list of individual characters.

PowerShell, 51 bytes
param($a,$n)-join($a|%{($_,("$_"*$n))[!($i++%$n)]})

Try it online!
Takes input as a char-array $a and the number $n. Loops through $a and each iteration either outputs the current letter $_ or the current letter multiplied by $n, based on an index into a pseudo-ternary. The index chooses between the two based off of incrementing $i and then modulo $n. Those letters are then -joined back together and the string is left on the pipeline; output is implicit.

Python 3, 53 52 bytes
f=lambda x,n,i=0:x[i:]and n**(i%n<1)*x[i]+f(x,n,i+1)

Try it online!

Japt, 8 bytes
ËùDV*EvV

Test it online!
Explanation
 Ë    ùDV*EvV
UmDE{DùDV*EvV}   Ungolfed
                 Implicit: U = s, V = n
UmDE{        }   Replace each char D and (0-)index E in U by this function:
          EvV      Take 1 if the index is divisible by V; 0 otherwise.
        V*         Multiply this by V. This gives V for every Vth index; 0 for others.
     DùD           Pad D with itself to this length. This gives V copies of D for every
                   Vth index; 1 copy of D for others.
                 Implicit: output last expression

I have to credit the idea to use ù to @Shaggy's answer here. I don't know that I ever would have thought of it myself...

You see now why was so keen to see string padding added :) Nice solution. I was trying to get something to work with ë, for poops & giggles, but failed miserably!

Haskell, 51 46 bytes
Thanks @Laikoni for saving me 5 bytes!
n&s=do(m,c)<-zip[0..]s;c<$[0..(n-1)*0^mod m n]

Try it online!
Explanation/Ungolfed
The operator c <$ [a..b] replaces each element of the list [a,a+1...b] by c - so it's just a golfed replicate:
do(m,c)<-zip[0..]s;                                  -- with all (m,c) in the enumerated ([(0,a),(1,b)..]) input string, replace with
                   replicate (1 + (n-1)*0^mod m n) c -- either n or 1 times the character c (note that the list begins with 0, that's where the 1+ comes from)

J, 17 bytes
(#@]$[,1#~<:@[)#]

(...) # ] everything in parens creates the string for J's built in "copy" verb.  So, eg, if the left argument is 3, it creates the string 3 1 1 repeated as needed to equal the number of characters in the right arg ], which contains the string.  Which is to say, # solves the problem directly, assuming we can give it the correct left argument: 4 should be 4 1 1 1 repeated, and so on.
Examining #@]$[,1#~<:@[, we see it uses J's shape verb $ in the middle -- that's the main verb of this phrase...
To the left of $ is #@], meaning the length # of the right arg ].
To the right of $ is [,1#~<:@[, a 5 verb train.  The first train executed is...
1#~<:@[, which means 1 copied #~ (passive form of copy) one less than <: the left arg [.  This result is passed to the final fork:
[, ... meaning take the left arg, and append the result we just calculated, which is a string of 1s.

Try it online!

]#~[^0=(|i.@#) for 14 bytes

That's quite clever.  Your improvements to my posts are the best part of this site for me.

Perl 5, 37, 29 +1 (-p) bytes
-8 bytes thanks to Tom's comment.
$n=<>;s/./"@-"%$n?$&:$&x$n/ge

Try It Online

Can't think of a better approach right now, but I came up with a few ideas: $n=<>; instead of the BEGIN block and have n on the next line of input and replace $-[0] with "@-" since only the first number is evaluated in comparison. Also, if you take input of n via -i you can just use $^I instead of declaring and using $n, but since this is non-standard it might not fly... :)

Java 8, 100 76 bytes
s->n->{int i,k=0;for(char c:s)for(i=k++%n<1?n:1;i-->0;)System.out.print(c);}

-24 bytes thanks to @OliverGrégoire.
Explanation:
Try it here.
s->n->{                    // Method with char-array and int parameters and no return-type
  int i,k=0;               //  Index-integers
  for(char c:s)            //  Loop (1) over the characters of the input array
    for(i=k++%n<1?         //   If `k` is divisible by the input `n`:
         n                 //    Change `i` to `n`
        :                  //   Else:
         1;                //    Change `i` to 1
        i-->0;)            //   Inner loop (2) from `i` down to 0
      System.out.print(c); //    And print the current character that many times
                           //   End of inner loop (2) (implicit / single-line body)
                           //  End of loop (1) (implicit / single-line body)
}                          // End of method

Oops, I didn't see there was already a submission so I deleted mine. Here's it, shortened to 76 bytes: n->s->{int i,k=0;for(char c:s)for(i=k++%n<1?n:1;i-->0;)System.out.print(c);} (with a char[], instead of String.)

Rule of the thumb, if you have to declare exactly one String that will be returned, it's shorter to just print it out.

@OlivierGrégoire Oops.. Yes, I know that rule of thumb, just forgot to apply it this time.. And thanks for the saved bytes!

C# (.NET Core), 61 + 18 = 79 bytes
using System.Linq;
n=>m=>string.Concat(n.Select((c,i)=>new string(c,i%m<1?m:1)))

Try it online!

6502 machine code routine, 50 bytes
A0 01 84 97 88 84 9E 84 9F B1 FB F0 20 A4 9F 91 FD C6 97 D0 10 A6 FF CA F0
05 C8 91 FD D0 F8 84 9F A5 FF 85 97 E6 9E A4 9E E6 9F D0 DC A4 9F 91 FD 60

This is a position-independent subroutine expecting a pointer to the input string (0-terminated aka C-string) in $fb/$fc, a pointer to the output buffer in $fd/$fe and the count (n) in $ff. It uses simple indexing, so it's limited to a maximum output length of 255 characters (+ 0 byte) due to the 8bit architecture.
Explanation (commented disassembly):
 .rep:
A0 01       LDY #$01            ; init counter to next repetition sequence
84 97       STY $97
88          DEY                 ; init read and write index
84 9E       STY $9E             ; (read)
84 9F       STY $9F             ; (write)
 .rep_loop:
B1 FB       LDA ($FB),Y         ; read next character
F0 20       BEQ .rep_done       ; 0 -> finished
A4 9F       LDY $9F             ; load write index
91 FD       STA ($FD),Y         ; write next character
C6 97       DEC $97             ; decrement counter to nex rep. seq.
D0 10       BNE .rep_next       ; not reached yet -> next iteration
A6 FF       LDX $FF             ; load repetition counter
 .rep_seqloop:
CA          DEX                 ; and decrement
F0 05       BEQ .rep_seqdone    ; if 0, no more repetitions
C8          INY                 ; increment write index
91 FD       STA ($FD),Y         ; write character
D0 F8       BNE .rep_seqloop    ; and repeat for this sequence
 .rep_seqdone:
84 9F       STY $9F             ; store back write index
A5 FF       LDA $FF             ; re-init counter to next ...
85 97       STA $97             ; ... repetition sequence
 .rep_next:
E6 9E       INC $9E             ; increment read index
A4 9E       LDY $9E             ; load read index
E6 9F       INC $9F             ; increment write index
D0 DC       BNE .rep_loop       ; jump back (main loop)
 .rep_done:
A4 9F       LDY $9F             ; load write index
91 FD       STA ($FD),Y         ; and write terminating0-byte there
60          RTS                 ; done.

Example C64 machine code program using it:
This is a program in ca65-style assembler for the C64 using this routine (imported as rep):
REP_IN          = $fb
REP_IN_L        = $fb
REP_IN_H        = $fc

REP_OUT         = $fd
REP_OUT_L       = $fd
REP_OUT_H       = $fe

REP_N           = $ff

.import         rep

.segment "LDADDR"
                .word   $c000

.code
                jsr     $aefd           ; consume comma
                jsr     $ad9e           ; evaluate expression
                sta     REP_IN_L        ; store string length
                jsr     $b6a3           ; free string
                ldy     #$00            ; loop over string
readloop:       cpy     REP_IN_L        ; end of string?
                beq     termstr         ; then jump to 0-terminate string
                lda     ($22),y         ; read next character
                sta     in,y            ; store in input buffer
                iny                     ; next
                bne     readloop
termstr:        lda     #$00            ; load 0 byte
                sta     in,y            ; store in input buffer

                jsr     $b79b           ; read 8bit unsigned int
                stx     REP_N           ; store in `n`
                lda     #<in            ; (
                sta     REP_IN_L        ;   store pointer to
                lda     #>in            ;   to input string
                sta     REP_IN_H        ; )
                lda     #<out           ; (
                sta     REP_OUT_L       ;   store pointer to
                lda     #>out           ;   output buffer
                sta     REP_OUT_H       ; )
                jsr     rep             ; call function

                ldy     #$00            ; output result
outloop:        lda     out,y
                beq     done
                jsr     $ffd2
                iny
                bne     outloop
done:           rts

.bss
in:             .res    $100
out:            .res    $100

Online demo
Usage: sys49152,"[s]",[n], e.g. sys49152,"Hello, World!",3
Important: If the program was load from disk (like in the online demo), issue a new command first! This is necessary because loading a machine program trashes some C64 BASIC pointers.

MATL, 10 7 bytes
-3 bytes thanks to Luis Mendo!
tq:ghY"

Try it online!
Takes input as n and then S as a string/char array.
    % (implicit input)
    % stack: n
t   % duplicate
    % stack: n n
q   % decrement
    % stack: n n-1
:   % range
    % stack: n [1 2 ... n-1]
g   % convert to logical (nonzero->1, zero->0)
    % stack: n [1 1 ... 1]
h   % horizontal concatenate
    % stack: [n 1 1 ... 1]
Y"  % run-length decoding, taking the string as first input and recycling
    % the lengths [n 1 1 ... 1] as needed
    % (implicit output as string)

Python 2, 57 bytes
lambda s,n:''.join(c*[1,n][i%n<1]for i,c in enumerate(s))

Try it online!

Would indexing into the string rather than using enumerate be shorter?

@cairdcoinheringaahing i would have to use range(len()) in the end would be longer

56 bytes

Charcoal, 14 bytes
Ｎθ⪫ＥＳ⎇﹪κθι×ιθω

Try it online! Link is to verbose version of code. Takes input in the order n, s.

For some reason the TIO link has the arguments reversed. It was also for an older version of Charcoal; the -sl argument has since been renamed to -l. Current Charcoal also has the StringMap function which would save two bytes as it makes the Join unnecessary.

V, 13 bytes
"aDJòylÀpÀll

Try it online!
This is a really dumb workaround. òlhÀälÀlÀ<M-->l should work, but I can't for the life of me understand why, especially since manually doing lhÀälÀlÀ<M-->l repeated a bunch of times does work.
Hexdump:
00000000: 1822 6144 4af2 796c c070 c06c 6c         ."aDJ.yl.p.ll

Explanation:
<C-x>               " Decrement the number
       D            " Delete that number...
     "a             "   Into register 'a'
        J           " Remove the blank line
         ò          " Recursively...
          yl        "   Yank the letter under the cursor
            Àp      "   And paste it 'a' times
              Àl    "   Move 'a' times to the right ('l' for right)
                l   "   Move to the right one more time
                    " (implicit) end the loop

'l' for right ... I'm guessing that's a holdover Vim thing? Otherwise ... why?

@AdmBorkBork yeah l is right in vim.  it might be orthographically backwards, but it's geometrically correct: l is the rightmost letter key of the middle row.

@DJMcMayhem Right.  I made it right.

Pyth, 12 bytes
s*Vzm^Q!d%Uz

Try it here.

Mathematica, 71 bytes
""<>s[[i]]~t~If[i~Mod~#2==1,#2,1]~(t=Table)~{i,Tr[1^(s=Characters@#)]}&

Try it online!
saved -2 bytes by listening to user202729

I think Map over Characters may be shorter.

@user202729 ok! -2 bytes

Python 3, 58 bytes
Working on golfing it down.
I know there are already other Python answers, but I thought I'd post this one too seeing as it scores pretty well compared to the others, despite being a full function and not a lambda.
Takes input as function parameters, and prints to STDOUT.
def f(s,n,i=0):
 for c in s:print(end=[c,c*n][i%n<1]);i+=1

Try it online!
For one byte less (57), I coded a lambda, however similar answers have already been posted by other users:
lambda s,n:''.join([c,c*n][i%n<1]for i,c in enumerate(s))

Brain-Flak (BrainHack), 122 + 3 (-A) = 125 bytes
I am sure this is too long, but I spent quite a while looking and couldn't find any improvements.
([]){{}([(([{}]<>)<{({}<<>(({})<>)>())}{}{}>)<{({}<<>({}<>)>())}{}>]<>)([][()])}({}{}<>){({}{(<()>)}{}[()])}{}{({}<>)<>}<>

Try it online!

05AB1E, 12 11 bytes
vX‚RNIÖèy×?

Try it online!
Explanation
v             # for each letter in the input string
       è      # index into
 X‚           # the list [input_int,1]
   R          # reversed
    NIÖ       # with letter_index % input_int == 0
        y×    # repeat the current letter this many times
          ?   # print

K (oK), 23 19 bytes
Solution:
{,/(1|y*~y!!#x)#'x}

Try it online!
Examples:
> {,/(1|y*~y!!#x)#'x}["Hello, World!";3]
"HHHellllo,   Worrrld!!!"
> {,/(1|y*~y!!#x)#'x}["Code golf";1]
"Code golf"
> {,/(1|y*~y!!#x)#'x}["abcdefghijklm";10]
"aaaaaaaaaabcdefghijkkkkkkkkkklm"

Explanation:
{,/(1|y*~y!!#x)#'x} / the solution
{                 } / lambda function with x and y as implicit parameters
   (          )     / do everything in brackets together
            #x      / count x, #"Hello, World!" -> 13
           !        / til, !13 -> 0 1 2 3 4 5 6 7 8 9 10 11 12
         y!         / y modulo, 3!0 1 2 3 4 5 6 7 8 9 10 11 12 -> 0 1 2 0 1 2 0 1 2 0 1 2 0
        ~           / not, ~0 1 2 0 1 2 0 1 2 0 1 2 0 -> 1 0 0 1 0 0 1 0 0 1 0 0 1
      y*            / multiply by y, 3*1 0 0 1 0 0 1 0 0 1 0 0 1 -> 3 0 0 3 0 0 3 0 0 3 0 0 3
    1|              / min of 1 and, 1|3 0 0 3 0 0 3 0 0 3 0 0 3 -> 3 1 1 3 1 1 3 1 1 3 1 1 3
                #'x / take each parallel, 1 2 3#'"abc" -> "a", "bb", "ccc"
 ,/                 / flatten the list, "a", "bb", "ccc" -> "abbccc"

Notes:

-4 bytes with different approach

Excel VBA, 71 Bytes
Anonymous VBE immediate window function that take input from range [A1:B1] and outputs to the VBE immediate window.
For i=1To[Len(A1)]:[C1]=i:?[Rept(Mid(A1,C1,1),B1^(Mod(C1,B1)=1))];:Next