Skip to main content
4 of 9
golfed more
Kapocsi
  • 221
  • 1
  • 4

#Python 3, ~~104~~ 74 bytes

def a(n):x=(int((n-1)**.5)+1)//2;return 8*x**2+(6,-2)[n<=4*x**2+2*x]*x+2-n
Kapocsi
  • 221
  • 1
  • 4