cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A227790 Difference between 3n^2 and the nearest square number.

Original entry on oeis.org

1, 3, 2, 1, 6, 8, 3, 4, 13, 11, 2, 9, 22, 12, 1, 16, 26, 11, 6, 25, 27, 8, 13, 36, 26, 3, 22, 48, 23, 4, 33, 47, 18, 13, 46, 44, 11, 24, 61, 39, 2, 37, 71, 32, 9, 52, 66, 23, 22, 69, 59, 12, 37, 88, 50, 1, 54, 92, 39, 16, 73, 83, 26, 33, 94, 72, 11, 52, 117, 59, 6, 73, 111, 44, 25, 96, 98, 27, 46, 121
Offset: 1

Views

Author

Ralf Stephan, Sep 23 2013

Keywords

Comments

max(a(n)/n) approaches sqrt(3), and the indices of the maxima are apparently in A041017.

Examples

			a(9) = 13 because the difference between 3*9^2 = 243 and the nearest square number (256) is 13.
		

Crossrefs

Programs

  • PARI
    a(n)=min(3*n^2-(floor(n*sqrt(3)))^2,(1+floor(n*sqrt(3)))^2-3*n^2)

Formula

a(n) = min (A033428(n)-A022838(n)^2, (1+A022838(n))^2-A033428(n)) = min [3*n^2 - (floor[n*sqrt(3)])^2, (1 + floor[n*sqrt(3)])^2 - 3*n^2].