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.

A085047 a(n) is the least number not already used such that the arithmetic mean of the first n terms is a square.

Original entry on oeis.org

1, 7, 4, 24, 9, 51, 16, 88, 25, 135, 36, 192, 49, 259, 64, 336, 81, 423, 100, 520, 121, 627, 144, 744, 169, 871, 196, 1008, 225, 1155, 256, 1312, 289, 1479, 324, 1656, 361, 1843, 400, 2040, 441, 2247, 484, 2464, 529, 2691, 576, 2928, 625, 3175, 676, 3432, 729
Offset: 1

Views

Author

Amarnath Murthy, Jun 20 2003

Keywords

Comments

This is very nearly a linear recurrence, but the distinctness requirement occasionally foils it. - Charles R Greathouse IV, Nov 07 2014

Examples

			(a(1) + a(2) + a(3) + a(4) + a(5))/5 = (1+7+4+24+9)/5 = 9 = 3^2.
		

Crossrefs

Cf. A168668.

Programs

  • Maple
    b:= proc(n) is(n>1) end:
    s:= proc(n) option remember;
          `if`(n=1, 1, s(n-1)+a(n))
        end:
    a:= proc(n) option remember; local k;
          if n=1 then 1
        else for k from n-irem(s(n-1),n) by n
             do if b(k) and issqr((s(n-1)+k)/n)
                   then b(k):=false; return k
                fi
             od
          fi
        end:
    seq(a(n), n=1..150);  # Alois P. Heinz, Nov 07 2014
  • Mathematica
    Clear[a, b, s]; b[n_] := n>1; s[n_] := s[n] = If[n == 1, 1, s[n-1] + a[n]]; a[n_] := a[n] = Module[{k}, If [n == 1, 1, For[k = n - Mod[s[n-1], n], True, k = k+n, If[b[k] && IntegerQ[Sqrt[(s[n-1]+k)/n]], b[k] = False; Return[k]]]]]; Table[a[n], {n, 1, 150}] (* Jean-François Alcover, Jun 10 2015, after Alois P. Heinz *)
  • PARI
    v=[1]; n=1; while(#v<50, s=(n+vecsum(v))/(#v+1); if(type(s)=="t_INT", if(issquare(s)&&!vecsearch(vecsort(v), n), v=concat(v, n); n=0)); n++); v \\ Derek Orr, Nov 05 2014, edited Jun 26 2015

Formula

a(2*n-1) = n^2; a(2*n) = n*(2+5*n). Also, (1/(2*n))*(Sum_{i=1..n} i^2 + i*(2+5*i)) = (n+1)^2 and (1/(2*n-1))*(Sum_{i=1..n} i^2 + (i-1)*(5*i-3)) = k^2. Thus the arithmetic mean of the first 2*n terms is (n+1)^2 and the arithmetic mean of the first 2*n-1 terms is n^2. - Derek Orr, Jun 26 2015

Extensions

More terms from David Wasserman, Jan 11 2005
Incorrect formulas and programs removed by Charles R Greathouse IV, Nov 07 2014