[Question]
  [
This challenge is about building a chessboard in which the square size, instead of being constant across the board, follows a certain non-decreasing sequence, as described below.
The board is defined iteratively. A board of size \$n \times n\$ is enlarged to size \$(n+k)\times(n+k)\$ by extending it down and to the right by a "layer" of squares of size \$k\$, where \$k\$ is the greatest divisor of \$n\$ not exceeding \$\sqrt{n}\$. The squares in the diagonal are always of the same colour.
Specifically, consider the board with colours represented as `#` and `+`.
1. Initialize the chessboard to
```
#
```
2. The board so far has size \$1\times 1\$. The only divisor of \$1\$ is \$1\$, and it does not exceed \$\sqrt{1}\$. So we take \$k=1\$, and extend the board by adding a layer of squares of size \$1\$, with `#` in the diagonal:
```
#+
+#
```
3. The board built so far has size \$2 \times 2\$. The divisors of \$2\$ are \$1,2\$, and the maximum divisor not exceeding \$\sqrt{2}\$ is \$1\$. So again \$k=1\$, and the board is extended to
```
#+#
+#+
#+#
```
4. Size is \$3 \times 3\$. \$k=1\$. Extend to
```
#+#+
+#+#
#+#+
+#+#
```
5. Size is \$4 \times 4\$. Now \$k=2\$, because \$2\$ is the maximum divisor of \$4\$ not exceeding \$\sqrt 4\$. Extend with a layer of thickness \$2\$, formed by squares of size \$2\times 2\$, with colour `#` in the diagonal:
```
#+#+##
+#+###
#+#+++
+#+#++
##++##
##++##
```
6. Size is \$6 \times 6\$. Now \$k=2\$. Extend to size \$8 \times 8\$. Now \$k=2\$. Extend to size \$10 \times 10\$. Now \$k=2\$. Extend to size \$12 \times 12\$. Now \$k=3\$. Extend to size \$15\$:
```
#+#+##++##++###
+#+###++##++###
#+#+++##++#####
+#+#++##++##+++
##++##++##+++++
##++##++##+++++
++##++##++#####
++##++##++#####
##++##++##++###
##++##++##+++++
++##++##++##+++
++##++##++##+++
###+++###+++###
###+++###+++###
###+++###+++###
```
Note how the most recently added squares, of size \$3 \times 3\$, have sides that partially coincide with those of the previously added squares of size \$ 2 \times 2 \$.
The sequence formed by the values of \$k\$ is non-decreasing:
```
1 1 1 2 2 2 2 3 3 3 3 4 4 4 6 6 6 6 6 6 ...
```
and does not seem to be in OEIS. However, its cumulative version, which is the sequence of sizes of the board, is [A139542](http://oeis.org/A139542) (thanks to [@Arnauld](https://codegolf.stackexchange.com/users/58563/arnauld) for noticing).
# The challenge
**Input**: a positive integer \$S\$ representing the number of layers in the board. If you prefer, you may also get \$S-1\$ instead of \$S\$ as input (\$0\$-indexed); see below.
**Output**: an ASCII-art representation of a board with \$S\$ layers.
* Output may be through STDOUT or an argument returned by a function. In this case it may be a string with newlines, a 2D character array or an array of strings.
* You can consistently choose **any two characters** for representing the board.
* You can consistently choose the **direction** of growth. That is, instead of the above representations (which grow downward and rightward), you can produce any of its reflected or rotated versions.
* Trailing or leading **space** is allowed (if output is through STDOUT), as long as space is not one of the two characters used for the board.
* You can optionally use "**\$0\$-indexed**" input; that is, take as input \$S-1\$, which specifies a board with \$S\$ layers.
Shortest code in bytes wins.
# Test cases
`1`:
```
#
```
`3`:
```
#+#
+#+
#+#
```
`5`:
```
#+#+##
+#+###
#+#+++
+#+#++
##++##
##++##
```
`6`:
```
#+#+##++
+#+###++
#+#+++##
+#+#++##
##++##++
##++##++
++##++##
++##++##
```
`10`:
```
#+#+##++##++###+++
+#+###++##++###+++
#+#+++##++#####+++
+#+#++##++##+++###
##++##++##+++++###
##++##++##+++++###
++##++##++#####+++
++##++##++#####+++
##++##++##++###+++
##++##++##+++++###
++##++##++##+++###
++##++##++##+++###
###+++###+++###+++
###+++###+++###+++
###+++###+++###+++
+++###+++###+++###
+++###+++###+++###
+++###+++###+++###
```
`15`:
```
#+#+##++##++###+++###+++####++++####
+#+###++##++###+++###+++####++++####
#+#+++##++#####+++###+++####++++####
+#+#++##++##+++###+++#######++++####
##++##++##+++++###+++###++++####++++
##++##++##+++++###+++###++++####++++
++##++##++#####+++###+++++++####++++
++##++##++#####+++###+++++++####++++
##++##++##++###+++###+++####++++####
##++##++##+++++###+++#######++++####
++##++##++##+++###+++#######++++####
++##++##++##+++###+++#######++++####
###+++###+++###+++###+++++++####++++
###+++###+++###+++###+++++++####++++
###+++###+++###+++###+++++++####++++
+++###+++###+++###+++###++++####++++
+++###+++###+++###+++#######++++####
+++###+++###+++###+++#######++++####
###+++###+++###+++###+++####++++####
###+++###+++###+++###+++####++++####
###+++###+++###+++###+++++++####++++
+++###+++###+++###+++###++++####++++
+++###+++###+++###+++###++++####++++
+++###+++###+++###+++###++++####++++
####++++####++++####++++####++++####
####++++####++++####++++####++++####
####++++####++++####++++####++++####
####++++####++++####++++####++++####
++++####++++####++++####++++####++++
++++####++++####++++####++++####++++
++++####++++####++++####++++####++++
++++####++++####++++####++++####++++
####++++####++++####++++####++++####
####++++####++++####++++####++++####
####++++####++++####++++####++++####
####++++####++++####++++####++++####
```
`25`:
```
#+#+##++##++###+++###+++####++++##########++++++######++++++######++++++++++++++########++++++++########++++++++########
+#+###++##++###+++###+++####++++##########++++++######++++++######++++++++++++++########++++++++########++++++++########
#+#+++##++#####+++###+++####++++##########++++++######++++++######++++++++++++++########++++++++########++++++++########
+#+#++##++##+++###+++#######++++##########++++++######++++++######++++++++++++++########++++++++########++++++++########
##++##++##+++++###+++###++++####++++######++++++######++++++######++++++++++++++########++++++++########++++++++########
##++##++##+++++###+++###++++####++++######++++++######++++++######++++++++++++++########++++++++########++++++++########
++##++##++#####+++###+++++++####++++++++++######++++++######++++++######++++++++########++++++++########++++++++########
++##++##++#####+++###+++++++####++++++++++######++++++######++++++######++++++++########++++++++########++++++++########
##++##++##++###+++###+++####++++####++++++######++++++######++++++##############++++++++########++++++++########++++++++
##++##++##+++++###+++#######++++####++++++######++++++######++++++##############++++++++########++++++++########++++++++
++##++##++##+++###+++#######++++####++++++######++++++######++++++##############++++++++########++++++++########++++++++
++##++##++##+++###+++#######++++####++++++######++++++######++++++##############++++++++########++++++++########++++++++
###+++###+++###+++###+++++++####++++######++++++######++++++######++++++########++++++++########++++++++########++++++++
###+++###+++###+++###+++++++####++++######++++++######++++++######++++++########++++++++########++++++++########++++++++
###+++###+++###+++###+++++++####++++######++++++######++++++######++++++########++++++++########++++++++########++++++++
+++###+++###+++###+++###++++####++++######++++++######++++++######++++++########++++++++########++++++++########++++++++
+++###+++###+++###+++#######++++##########++++++######++++++######++++++++++++++########++++++++########++++++++########
+++###+++###+++###+++#######++++##########++++++######++++++######++++++++++++++########++++++++########++++++++########
###+++###+++###+++###+++####++++####++++++######++++++######++++++######++++++++########++++++++########++++++++########
###+++###+++###+++###+++####++++####++++++######++++++######++++++######++++++++########++++++++########++++++++########
###+++###+++###+++###+++++++####++++++++++######++++++######++++++######++++++++########++++++++########++++++++########
+++###+++###+++###+++###++++####++++++++++######++++++######++++++######++++++++########++++++++########++++++++########
+++###+++###+++###+++###++++####++++++++++######++++++######++++++######++++++++########++++++++########++++++++########
+++###+++###+++###+++###++++####++++++++++######++++++######++++++######++++++++########++++++++########++++++++########
####++++####++++####++++####++++##########++++++######++++++######++++++########++++++++########++++++++########++++++++
####++++####++++####++++####++++##########++++++######++++++######++++++########++++++++########++++++++########++++++++
####++++####++++####++++####++++##########++++++######++++++######++++++########++++++++########++++++++########++++++++
####++++####++++####++++####++++##########++++++######++++++######++++++########++++++++########++++++++########++++++++
++++####++++####++++####++++####++++######++++++######++++++######++++++########++++++++########++++++++########++++++++
++++####++++####++++####++++####++++######++++++######++++++######++++++########++++++++########++++++++########++++++++
++++####++++####++++####++++####++++++++++######++++++######++++++##############++++++++########++++++++########++++++++
++++####++++####++++####++++####++++++++++######++++++######++++++##############++++++++########++++++++########++++++++
####++++####++++####++++####++++####++++++######++++++######++++++######++++++++########++++++++########++++++++########
####++++####++++####++++####++++####++++++######++++++######++++++######++++++++########++++++++########++++++++########
####++++####++++####++++####++++####++++++######++++++######++++++######++++++++########++++++++########++++++++########
####++++####++++####++++####++++####++++++######++++++######++++++######++++++++########++++++++########++++++++########
######++++++######++++++######++++++######++++++######++++++######++++++++++++++########++++++++########++++++++########
######++++++######++++++######++++++######++++++######++++++######++++++++++++++########++++++++########++++++++########
######++++++######++++++######++++++######++++++######++++++######++++++++++++++########++++++++########++++++++########
######++++++######++++++######++++++######++++++######++++++######++++++++++++++########++++++++########++++++++########
######++++++######++++++######++++++######++++++######++++++######++++++########++++++++########++++++++########++++++++
######++++++######++++++######++++++######++++++######++++++######++++++########++++++++########++++++++########++++++++
++++++######++++++######++++++######++++++######++++++######++++++##############++++++++########++++++++########++++++++
++++++######++++++######++++++######++++++######++++++######++++++##############++++++++########++++++++########++++++++
++++++######++++++######++++++######++++++######++++++######++++++##############++++++++########++++++++########++++++++
++++++######++++++######++++++######++++++######++++++######++++++##############++++++++########++++++++########++++++++
++++++######++++++######++++++######++++++######++++++######++++++##############++++++++########++++++++########++++++++
++++++######++++++######++++++######++++++######++++++######++++++##############++++++++########++++++++########++++++++
######++++++######++++++######++++++######++++++######++++++######++++++++++++++########++++++++########++++++++########
######++++++######++++++######++++++######++++++######++++++######++++++++++++++########++++++++########++++++++########
######++++++######++++++######++++++######++++++######++++++######++++++++++++++########++++++++########++++++++########
######++++++######++++++######++++++######++++++######++++++######++++++++++++++########++++++++########++++++++########
######++++++######++++++######++++++######++++++######++++++######++++++++++++++########++++++++########++++++++########
######++++++######++++++######++++++######++++++######++++++######++++++++++++++########++++++++########++++++++########
++++++######++++++######++++++######++++++######++++++######++++++######++++++++########++++++++########++++++++########
++++++######++++++######++++++######++++++######++++++######++++++######++++++++########++++++++########++++++++########
++++++######++++++######++++++######++++++######++++++######++++++##############++++++++########++++++++########++++++++
++++++######++++++######++++++######++++++######++++++######++++++##############++++++++########++++++++########++++++++
++++++######++++++######++++++######++++++######++++++######++++++##############++++++++########++++++++########++++++++
++++++######++++++######++++++######++++++######++++++######++++++##############++++++++########++++++++########++++++++
######++++++######++++++######++++++######++++++######++++++######++++++########++++++++########++++++++########++++++++
######++++++######++++++######++++++######++++++######++++++######++++++########++++++++########++++++++########++++++++
######++++++######++++++######++++++######++++++######++++++######++++++########++++++++########++++++++########++++++++
######++++++######++++++######++++++######++++++######++++++######++++++########++++++++########++++++++########++++++++
######++++++######++++++######++++++######++++++######++++++######++++++++++++++########++++++++########++++++++########
######++++++######++++++######++++++######++++++######++++++######++++++++++++++########++++++++########++++++++########
++++++######++++++######++++++######++++++######++++++######++++++######++++++++########++++++++########++++++++########
++++++######++++++######++++++######++++++######++++++######++++++######++++++++########++++++++########++++++++########
++++++######++++++######++++++######++++++######++++++######++++++######++++++++########++++++++########++++++++########
++++++######++++++######++++++######++++++######++++++######++++++######++++++++########++++++++########++++++++########
++++++######++++++######++++++######++++++######++++++######++++++######++++++++########++++++++########++++++++########
++++++######++++++######++++++######++++++######++++++######++++++######++++++++########++++++++########++++++++########
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########++++++++########
```
  
[Answer]
# [Canvas](https://github.com/dzaima/Canvas), ~~34~~ 32 [bytes](https://github.com/dzaima/Canvas/blob/master/files/chartable.md)
```
０#０⁸［#+¶+#ｘｘ＊ｙｘ＋ｍ⤢αｍ；ｎｌｗ√｛ｙ；％‽²Ｘ
```
[Try it here!](https://dzaima.github.io/Canvas/?u=JXVGRjEwJTIzJXVGRjEwJXUyMDc4JXVGRjNCJTIzKyVCNislMjMldUZGNTgldUZGNTgldUZGMEEldUZGNTkldUZGNTgldUZGMEIldUZGNEQldTI5MjIldTAzQjEldUZGNEQldUZGMUIldUZGNEUldUZGNEMldUZGNTcldTIyMUEldUZGNUIldUZGNTkldUZGMUIldUZGMDUldTIwM0QlQjIldUZGMzg_,i=MTA_,v=8)
[Answer]
# [Python 2](https://docs.python.org/2/), ~~217~~ ~~215~~ 212 bytes
```
def f(x):
 b=['1'];n=1
 for i in range(x):P=max(j*(n%j<(j<=n**.5))for j in range(1,1+n));n+=P;b=[l+P*`j/P%2^i%2`for j,l in enumerate(b)];s=len(b[0]);b+=[((v*P+`1^int(v)`*P)*s)[:s]for v in b[0][len(b):]]
 return b
```
[Try it online!](https://tio.run/##Rc@xboMwEIDhnafwgrizURKjdijE7@DddQSoprVFjsgQlDw9xRnaxcPpu1/n23P5majati83sAEeWGesV6aQhW1IyYwNU2SeeWKxo2@XgFbX7gGBA@XhDOGsiPPDO2KS4V/KUgpCbEgo3ezJUWjehqPOq4vPq/alyzF5R/eri93ioEfbzGp0BL05WWx6oQzAyrVo5cXTAiu2XCOf0dSzTYk1BRI2ry2src1YdMs97uPt7/hT@VZ@7F@7xb3Cik8qyvQcwuQJBvCI2y8 "Python 2 – Try It Online")
0-indexed, uses `0` and `1` as characters
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~40~~ 31 bytes
```
1SÆD>Ðḟ½ƊṀṭƲ³¡Äż$Ḷ:Ḃ^þ`ʋ/€ḷ""/Y
```
[Try it online!](https://tio.run/##AUQAu/9qZWxsef//MVPDhkQ@w5DhuJ/CvcaK4bmA4bmtxrLCs8Khw4TFvCThuLY64biCXsO@YMqLL@KCrOG4tyIiL1n///8xNQ "Jelly – Try It Online")
A full program taking the zero-indexed \$S-1\$ as input and writing to stdout ASCII art using 0 = #, 1 = +. 
Without the trailing `Y`, this returns a list of lists of integers, but this is out of spec for this challenge. 
### Explanation
This program works in three stages. 
1. Generate a list of values of \$k\$ and the cumulative sum of \$k\$
2. Generate a checkerboard for each of these with the tile size of \$k\$ and the board size of the cumulative sum
3. Work through the list of checkerboards, each time replacing the top-left section of the next board with the existing board.
**Stage 1**
```
1                 | Start with 1
           Ʋ³¡    | Loop through the following the number of times indicated by the first argument to the program; this generates a list of values of k
 S                | - Sum
        Ɗ         | - Following three links as a monad 
  ÆD              |   - List of divisors
    >Ðḟ½          |   - Exclude those greater than the square root
         Ṁ        |   - Maximum
          ṭ       | - Concatenate this to the end of the current list of values of k 
              Äż$ | Zip the cumulative sum of the values of k with the values
```
**Stage 2**
```
      ʋ/€ | For each pair of k and cumulative sum, call the following as a dyad with the cumulative sum of k as the left argument and k as the right (e.g. 15, 3)
Ḷ         | - Lowered range [0, 1 ... , 13, 14]
 :        | - Integer division by k [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]
  Ḃ       | - Mod 2 [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]
   ^þ`    | - Outer product using xor function and same argument to both side
```
**Stage 3**
```
   /  | Reduce using the following:
ḷ""   | - Replace the top left portion of the next matrix with the current one
    Y | Finally join by newlines
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~184~~ ~~178~~ ~~176~~ 169 bytes
```
def h(j,a=['1'],R=range):
 for i in R(j):L=len(a);k=max(x for x in R(1,L+1)if(x*x<=L)>L%x);a=[a[m]+k*`(i+m/k)%2`for m in R(L)]+[((`i%2`*k+`~i%2`*k)*L)[:L+k]]*k
 return a
```
[Try it online!](https://tio.run/##PY7BboMwEETP4St8idi1UROQejF1v8Anro4lLAXC4mIii0rupb9OaWhzG72nGc39axnmUK3rtevZAGPhlMnL3BaNii7cOpQZ6@fIiFFgDYwotfroAjisvZpcgvTQaddloUWJ1EPi6U1pfNfHhPU26cxkhectkJhOHo9V@9ua9pZGKwxASxvmXrTfe0Cu0UgtvLXcZyx2y2cMzK3PO4@DUJ5RmOrVyuxwjxQWRv8hv4T8ZZwpwACE@IfXHw "Python 2 – Try It Online")
Uses `1`, `0` for `#`, `-`; uses `0`-indexing.
[Answer]
# JavaScript (ES7), 164 bytes
Input is 0-indexed. Outputs a matrix with \$0\$ for `#` and \$1\$ for `+`.
```
n=>(b=[1],g=(a,w,d=w**.5|0)=>b[n]?a:w%d?g(a,w,d-1):g(a.concat(Array(d).fill(b.push(d)&&i++)),w+d))([0],i=1).map((_,y,a)=>a.map((_,x)=>(x/b[v=a[x>y?x:y]]^y/b[v])&1))
```
[Try it online!](https://tio.run/##XY5BUoNAEEX3OUUvFLrDZASr3IAD5QW8AI5mgICkcIYaYoCKOTtOjG5c/f/6d3X/vTqqobRtf9hoU@2WWixapFiIPJKsEajYyCoxrtf84SskkRa5lpmKx9sqa67hJqLYWV4aXaoDPlmrZqyI123XYcH7z@Hdoee1QUDExqAiwjyUrBUR8Q/VI76xmSl3W/3h5ACnuyI/CpVP6ZxN8Szl63yZSPIioqU2FjUICBPQ8Aj3F3UP4LQCcE0G0@14ZxrcPrulm5M@x1tK/mU16msDCyIFy/em1ej7RL/uRfsEAfxosjov3w "JavaScript (Node.js) – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 37 bytes
```
ＦＮ«≔⊕⌈Φ₂⊕Ｌυ¬﹪Ｌυ⊕κηＦη«ＰL⭆⊞Ｏυω§#+÷⁻κμη↙
```
[Try it online!](https://tio.run/##VU67bsMwEJvtrxDS5YQqQ5cOyRQgKBDASovmC1T7YgnRw5FPToAi367KXtpyIkjeka1WsQ3K5nwOkcHBD4mOyX1hBM7Zd13txtH0vhhtRIeesAOp7sYlB2/GUsmdrklF/AyB/qUa9D1pSJxzwY7FlKFLNvzqgv2NX/gCwTTf1tUyRi8DKpksmSEaT7BpBDtRob1UA3ykUb8PGBWFCEmwW7ne0cF3eIfV0/NqLqC9mUyHII1PI1wEc0tFwXZ@HSaEzT7cfINnmqVH/cj55TWvJ/sD "Charcoal – Try It Online") Link is to verbose version of code. 1-indexed. Output grows down and left (down and right costs an extra byte, but can grow up for the same byte count). Explanation:
```
ＦＮ«
```
Loop \$S\$ times.
```
≔⊕⌈Φ₂⊕Ｌυ¬﹪Ｌυ⊕κη
```
Calculate \$k\leq\sqrt{n+1}\$. This only makes a difference when \$n=0\$ in which case this formula allows \$k=1\$.
```
Ｆη«
```
Loop \$k\$ times, once for each new row and column.
```
ＰL⭆⊞Ｏυω§#+÷⁻κμη
```
Output the row and column, being sure to alternate between the `#` and `+` characters in such a way that `#` is always the first character but that there is a boundary at the end of the string (because we're drawing from the diagonal outwards). `⊞Ｏυω` makes each row one character longer each time, which also keeps track of \$n\$ as the length.
```
↙
```
Move down and left ready for the next row.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~43~~ 42 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
$G©ÐX‚ˆÑʒ®>t‹}àDU+}¯εÝ`θ÷É¨Dδ^}RζεðKζðδK€θ
```
Inspired by [*@NickKennedy*'s Jelly answer](https://codegolf.stackexchange.com/a/185762/52210), and the trailing portion `ζεðKζðδK€θ` is a port from [*@Emigna*'s 05AB1E answer here](https://codegolf.stackexchange.com/a/186372/52210).
Returns a matrix of `0` instead of `#` and `1` instead of `+`.
[Try it online](https://tio.run/##AV4Aof9vc2FiaWX//yRHwqnDkFjigJrLhsORypLCrj504oC5fcOgRFUrfcKvzrXDnWDOuMO3w4nCqETOtF59Us62zrXDsEvOtsOwzrRL4oKszrj/Siz/MTX/LS1uby1sYXp5) or [try it online by outputting the first \$[2,n]\$ results](https://tio.run/##AYMAfP9vc2FiaWX/SUVOMkBpTiJJbnB1dDogw78KT3V0cHV0OiIs/zFOR8Kpw5BY4oCay4bDkcqSwq4@dOKAuX3DoERVK33Cr861w51gzrjDt8OJwqhEzrRefVLOts61w7BLzrbDsM60S@KCrM64/0osfcK2P2ApXDFV/zE2/y0tbm8tbGF6eQ) (`J,` in the footer and the `--no-lazy` flag are to pretty-print the resulting matrix).
**Explanation:**
```
$                # Push 1 and the input
 G               # Loop the input - 1 amount of times:
  ©              #  Store the top of the stack in variable `r` (without popping)
   Ð             #  And triplicate the top as well
    X‚           #  Pair it with variable `X` (which is 1 by default)
      ˆ          #  And pop and store this pair in the global array
    Ñ            #  Get the divisors of the integer we triplicated
     ʒ    }à     #  Get the highest divisor which is truthy for:
         ‹       #   Where the divisor integer is smaller than
      ®>t        #   the square root of `r+1`
            DU   #  Store a copy of this largest filtered divisor as new variable `X`
              +  #  And add it to the triplicated integer
 }¯              # After the loop: push the global array
   ε             # Map each pair to:
    Ý θ          #  Convert the first value in the pair to a list in the range [0,n]
     `           #  and push both this list and the second value to the stack
       ÷         # Integer-divide each value in the list by the second value
        É        # Check for each value if it's even (1 if even; 0 if odd)
         ¨       # Remove the last item
          Dδ     # Loop double vectorized over this list:
            ^    #  And XOR the values with each other
   }R            # After the map: reverse the list of digit-matrices
     ζ           # Zip/transpose; swapping rows and columns, with a space as filler
      ε          # map each matrix to:
       ðK        #  Remove all spaces from the current matrix
         ζ       #  Zip/transpose with a space as filler again
          ðδK    #  Deep remove all spaces
             €θ  #  Then only leave the last values of each row
                 # (after which the resulting matrix of 0s and 1s is output implicitly)
```
[Answer]
## Haskell, ~~149~~ 146 bytes
```
(iterate g["#"]!!)
g b|let e=(<$[1..d]);l=length b;d=last[i|i<-[1..l],i*i<=l,mod l i<1];m="+#"++m=(e$take(l+d)$e=<<'#':m)++zipWith(++)(e=<<e<$>m)b
```
This is 0 indexed, returns a list of strings and grows upwards and leftwards.
[Try it online!](https://tio.run/##TckxbsIwFADQnVN8EkvYmETQsbFzAjp16BCsyiE/icW3sbBRpYqzNy1b1/dmmy5ItIz6tHCX8WYzwtQVZWHWa7GaoH8QZkDNFesOdT0Y0ZAmDFOeoW8GTTblzj2cqp5NZue2Tmna@esABE4dTON1IctCSq85smwvyEkOgqFWalNuXr2Q8tvFD5dnLqXgT0fFWi/6xVsXQIO38e0T@ClA1UK85/d8Owbgab5@QRDQ/sd7IBcwAYPx7wR0@7p@2ZvV8nMeyU5pqc4x/gI "Haskell – Try It Online")
```
(iterate g["#"]!!)                    -- start with ["#"], repeatedly add a layer
                                      -- (via function 'g'), collect all results in
                                      -- a list and index it with the input number
g b | let                             -- add a single layer to chessboard 'b'
 l=length b                           -- let 'l' be the size of 'b'
 d=last[i|i<-[1..l],i*i<=l,mod l i<1] -- let 'd' be the size of the new layer
 e=(<$[1..d])                         -- let 'e' be a functions that makes 'd'
                                      --   copies of it's argument
 m="#+"++m                            -- let 'm' be an infinite string of "+#+#+..."
 =                                    -- return
              zipWith(++)             --   concatenate pairwise
                         (e=<<e<$>m)  --   a list of squares made by expanding each
                                      --   char in 'm' to size 'd'-by-'d'
                                    b --   and 'b' (zipWith truncates the infinite
                                      --   list of squares to the length of 'b')
                                      --
           ++                         --   and prepend
                                      --
(e$take(l+d)$e=<<'#':m)               --   the top layer, i.e. a list of 'd' strings
                                      --   each with the pattern 'd' times '#'
                                      --   followed by 'd' times '+', etc., each
                                      --   shortened to the correct size of 'l'+'g'
```
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~156~~ ~~144~~ ~~155~~ 154 bytes
*+11 to fix a bug reported by nimi.*
```
{$!=-1;join "
",(1,{my \k=max grep $_%%*,1.. .sqrt;++$!;flat .kv.map(->\i,\l {l~($!+i/k)%2+|0 x k}),substr(($!%2 x k~1-$!%2 x k)x$_,0,$_+k)xx k}...*)[$_]}
```
Roughly based on [Chas Brown's Python solution](https://codegolf.stackexchange.com/a/185754/14109). Takes S zero-indexedly. Outputs `0` and `1`.
[Try it online!](https://tio.run/##NcrRCoIwGIbh47yKX5mxufmnHgQx7EYyhkELU9OmhWJ666ZEZw/v99VXU@znst/qeB6IHfuhvFfZAxzLETQUQ9lDksdl2sHNXGsgynU9ESICNk/TSs6JLXWRtoD5G8u0pv4xyURSwFBMlNg82@XMjfgngA7ykYnmdWlaQ5fJjdY0hf6frCNKBIIovnB9I6LHTkSdx1laujIQIB5gsDZN2oOmRDH5s@NIa5y/ "Perl 6 – Try It Online")
]