g | x | w | all
Bytes Lang Time Link
008Japt m251015T164837ZShaggy
025Uiua251015T142747Zojdo
012Dyalog APL250923T033725ZAaron
014Ecmascript250925T203448ZJohn Bol
018Rust250925T195348Zhoelzeli
017R250924T162727ZM--
014x86_64 machine code250924T113252Zuser1290
00705AB1E250924T071821ZKevin Cr
010GolfScript250923T141355ZGlory2Uk
020C gcc250923T134529Zjdt
1365Nibbles250922T225602ZDominic
015Google Sheets250922T102412Zdoubleun

Japt -m, 8 bytes

1½*6n°U²

Try it

1½*6n°U²     :Implicit map of each U in input array
1½*          :1.5 multiplied by
   6n        :  6 subtracted from
     °U      :    Prefix increment U
       ²     :    Square

Uiua, 25 bytes

A naive implementation that actually sums the last 3 odd numbers. I like its basic "1-2-3" look:

/+↙¯3+1×2⇡ⁿ2÷2+1

Uiua Pad this online

Walkthrough

/+↙¯3+1×2⇡ⁿ2÷2+1

            ÷2+1  # convert line length (3,5,7) to line number (2,3,4)
          ⁿ2      # square it to derive sequence length N
     +1×2⇡        # convert to range of first N odd numbers
  ↙¯3             # take last 3 elements
/+                # calculate their sum

Dyalog APL, 14 13 12 bytes

-1 bytes thanks to @Tbw turning it into a tacit function -1 bytes thanks to @att mathing hard

New explanation:

1.5××⍨++⍨-5⍨­⁡​‎‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁣⁢‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁣‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏‏​⁡⁠⁡‌⁢⁢​‎‎⁡⁠⁤‏‏​⁡⁠⁡‌⁢⁣​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠‎⁡⁠⁣‏‏​⁡⁠⁡‌­
       +⍨     # ‎⁡N+N
         -    # ‎⁢  minus
          5⍨  # ‎⁣  just 5, as a function (for the train's sake)
      +       # ‎⁤Plus
    ×⍨        # ‎⁢⁡  N^2
   ×          # ‎⁢⁢Times
1.5           # ‎⁢⁣
💎

Created with the help of Luminespire.

Original explanation:

9-⍨1.5×2*⍨1+⊢­⁡​‎‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏‏​⁡⁠⁡‌­
          1+⊢  # ‎⁡1 plus the input
       2*⍨     # ‎⁢to the power of (backwards) 2
   1.5×        # ‎⁣times 1.5
💎

Created with the help of Luminespire.

Ecmascript, 15 14 bytes

n=>3*++n*n/2-9

Rust, 19 (thanks jdt!) 18 characters

|x|3*((x+2)*x-5)/2

try it out!

R, 23 17 bytes

\(n)1.5*(n+1)^2-9

Attempt This Online!

x86_64 machine code, 14 bytes

Running on Godbolt

0:  8d 47 01                lea    eax,[rdi+0x1]
3:  d1 e8                   shr    eax,1
5:  f6 e0                   mul    al
7:  6b c0 06                imul   eax,eax,0x6
a:  83 e8 09                sub    eax,0x9
d:  c3                      ret

(M+1)>>1 converts an odd number M (the input) to it's ordinal placement in the series of odd numbers (i.e. 1 = 1, 3 = 2, 5 = 3, ect)

((n*n)*2)-1 gives the last number on the nth line (which corresponds to the ordinal placement of the number of elements in the line, since line 1 has 1 element, line 2 has 3, line 3 has 5, and so on) (i.e. 2 = 7, 3 = 17, 4 = 31)

Calculating the sum of the last 3 numbers on line n given the last number i is simply i + (i - 2) + (i - 4). Noting that the calculation for i ends in -1 we can move that out of i to give (i - 1) + (i - 3) + (i - 5) which can be simplified to (i*3)-9. Expanding i to ((n*n)*2) then gives ((n*n)*2*3)-9 = ((n*n)*6)-9.

Thus, the solution:

; convert input to ordinal placement
lea eax, [rdi+1]
shr eax
; square ordinal placement = i
mul al
; (i*6)
imul eax, eax, 6
; (i*6)-9
sub eax, 9
ret

Works for (odd) line lengths between 3 and 509 inclusive, due to the use of mul al (al * al -> ax), since 509 is the 255th odd number and the next one (511, the 256th) would no longer fit in al. Because we only need to be able to handle odd inputs between 1 and 100 (and it seems unspecified what to do for n == 1) this is fine.

05AB1E, 7 bytes

>n3;*9-

Uses the same formula as other answers.
I/O as a list.

Try it online.

Of course, the order of these operands can be changed slightly for the same byte-count and result:

>n6-3;*

Try it online.

Explanation:

>        # Increase each value in the (implicit) input-list by 1
 n       # Square each
  3*     # Multiply each by 3
    ;    # Halve each
     9-  # Subtract 9 from each
         # (after which the resulting list is output implicitly)

  6-     # Subtract 6 from each
    3;*  # Multiply each by 1.5 (3 halved)

GolfScript, 10 bytes

This is not ruby though, but quite close to it.

~)2?3*2/9-

Try it online!

Explanation:
~          # take the input
 )         # increment by 1
  2?       # raise to power 2
    3*     # multiply by 3
      2/   # divide by 2
        9- # subtract 9

C (gcc), 20 bytes

f(n){n=++n*n*1.5-9;}

Try it online!

Nibbles, 13 nibbles (6.5 bytes)

/*-^+$~~6 3~

Attempt This Online!

enter image description here

Google Sheets, 15 bytes

=(A1+1)^2*3/2-9

Assumes flexible input. Put \$N\$ in cell A1 and the formula in cell B1. Uses the logic shown in the spoiler. Doesn't cover the case \$N = 1\$ as that doesn't seem to be required by the rules. To cover that case (22 bytes):

=max(1,(A1+1)^2*3/2-9)