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.

This page as a plain text file.
%I A085047 #31 Apr 11 2019 22:04:03
%S A085047 1,7,4,24,9,51,16,88,25,135,36,192,49,259,64,336,81,423,100,520,121,
%T A085047 627,144,744,169,871,196,1008,225,1155,256,1312,289,1479,324,1656,361,
%U A085047 1843,400,2040,441,2247,484,2464,529,2691,576,2928,625,3175,676,3432,729
%N A085047 a(n) is the least number not already used such that the arithmetic mean of the first n terms is a square.
%C A085047 This is very nearly a linear recurrence, but the distinctness requirement occasionally foils it. - _Charles R Greathouse IV_, Nov 07 2014
%H A085047 Alois P. Heinz, <a href="/A085047/b085047.txt">Table of n, a(n) for n = 1..10000</a>
%F A085047 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
%e A085047 (a(1) + a(2) + a(3) + a(4) + a(5))/5 = (1+7+4+24+9)/5 = 9 = 3^2.
%p A085047 b:= proc(n) is(n>1) end:
%p A085047 s:= proc(n) option remember;
%p A085047       `if`(n=1, 1, s(n-1)+a(n))
%p A085047     end:
%p A085047 a:= proc(n) option remember; local k;
%p A085047       if n=1 then 1
%p A085047     else for k from n-irem(s(n-1),n) by n
%p A085047          do if b(k) and issqr((s(n-1)+k)/n)
%p A085047                then b(k):=false; return k
%p A085047             fi
%p A085047          od
%p A085047       fi
%p A085047     end:
%p A085047 seq(a(n), n=1..150);  # _Alois P. Heinz_, Nov 07 2014
%t A085047 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_ *)
%o A085047 (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
%Y A085047 Cf. A168668.
%K A085047 nonn
%O A085047 1,2
%A A085047 _Amarnath Murthy_, Jun 20 2003
%E A085047 More terms from _David Wasserman_, Jan 11 2005
%E A085047 Incorrect formulas and programs removed by _Charles R Greathouse IV_, Nov 07 2014