%I #17 Sep 13 2019 22:33:13
%S 1,3,5,4,12,13,14,18,18,31,33,48,52,69,56,72,72,97,99,117,108,135,121,
%T 168,156,187,174,226,215,269,243,286,290,335,341,388,396,445,455,506,
%U 494,530,559,597,628,668,663,706,738,783,817,864,864,900,949,987,1038
%N a(n) is the absolute value of the alternating sum of the first n increasing perfect powers (A001597): 1, 1-4, 1-4+8, 1-4+8-9, ...
%F a(n) = abs(Sum_{k=1..n} (-1)^k*A001597(k)). - _Andrew Howroyd_, Sep 10 2019
%e For n=8: a(8) = |1 - 4 + 8 - 9 + 16 - 25 + 27 - 32|.
%t t = Select[Range@2400, # == 1 || GCD @@ Last /@ FactorInteger@# > 1 &]; Abs@ Accumulate[t (-1)^Range@ Length[t]] (* _Giovanni Resta_, Sep 11 2019 *)
%o (PARI) seq(n)={my(v=vector(n), i=0, k=0, s=0); while(i<#v, k++; if(ispower(k)||k==1, s=k-s; i++; v[i]=abs(s))); v} \\ _Andrew Howroyd_, Sep 10 2019
%Y Cf. A001597, A076408.
%K nonn
%O 1,2
%A _Richard Locke Peterson_, Sep 10 2019
|