# Concentric rings on a snub square tiling

## Ruby, 26 bytes

->n{~-n*12-496/4**n%4+1/n}


Try it online!

Revised version adding 1/n and subtracting 496/4**n%4 to get the +1,-3,-3,-1 offset for the first 4 terms.

## Ruby, 32 bytes

->n{n>4?~-n*12:[0,1,9,21,35][n]}


Try it online!

After 4, the sequence settles down to (n-1)*12. See diagram below (the equilateral triangles have been distorted into 45 degree isosceles triangles and the entire diagram rotated 45 degrees, but it remains topologically equivalent.)

## JavaScript (ES6), 23 bytes

Based on Level River St's answer.

n=>[1,5,13,7][--n]^n*12


Try it online!

### How?

We compute $$\(n-1)\times12\$$ and adjust the first 4 values with a XOR.

$$\begin{array}{c|c} n&1&2&3&4&5&6&7&8&9&10\\ \hline (n-1)\times12&0&12&24&36&48&60&72&84&96&108\\ \hline \text{XOR}&1&5&13&7&\color{grey}0&\color{grey}0&\color{grey}0&\color{grey}0&\color{grey}0&\color{grey}0\\ \hline a(n)&1&9&21&35&48&60&72&84&96&108 \end{array}$$

## 05AB1E, 9 bytes

<©12*3®cα


Try it online! or try a test suite.

<           # input - 1
12*       # multiply by 12
®     # push the register
3 c    # binomial coefficient(3, input - 1)
α   # absolute difference


With 0-indexing, this would be 7 bytes:

12*3Icα