Skip to main content
added 618 characters in body
Source Link
Jonathan Allan
  • 110.2k
  • 7
  • 65
  • 282

Jelly, 8 bytes

’3cạ×ʋ12

Try it online!

How?

’3cạ×ʋ12 - Link: integer, n
’        - decrement              (n-1)                1   2   3   4   5   6   7  ...
      12 - twelve                 12                  12  12  12  12  12  12 12  ...
     ʋ   - dyad:
 3       -   three                3                    3   3   3   3   3   3   3  ...
  c      -   choose               3C(n-1)              1   3   3   1   0   0   0  ...
    ×    -   multiply             (n-1)*12             0  12  24  36  48  60  72  ...
   ạ     -   absolute difference  |3C(n-1)-(n-1)*12|   1   9  21  35  48  60  72  ...

Jelly, 8 bytes

’3cạ×ʋ12

Try it online!

Jelly, 8 bytes

’3cạ×ʋ12

Try it online!

How?

’3cạ×ʋ12 - Link: integer, n
’        - decrement              (n-1)                1   2   3   4   5   6   7  ...
      12 - twelve                 12                  12  12  12  12  12  12 12  ...
     ʋ   - dyad:
 3       -   three                3                    3   3   3   3   3   3   3  ...
  c      -   choose               3C(n-1)              1   3   3   1   0   0   0  ...
    ×    -   multiply             (n-1)*12             0  12  24  36  48  60  72  ...
   ạ     -   absolute difference  |3C(n-1)-(n-1)*12|   1   9  21  35  48  60  72  ...
Source Link
Jonathan Allan
  • 110.2k
  • 7
  • 65
  • 282

Jelly, 8 bytes

’3cạ×ʋ12

Try it online!