OFFSET
0,4
FORMULA
a(2*k+1) = 2^k.
Specifically, both the nearest triangular number below: A006516(n) = A000217((2^n)-1) = 2^(2n-1) - 2^(n-1) and the nearest triangular number above: A007582(n) = A000217(2^n) = 2^(2n-1) + 2^(n-1) are at the same distance from 2^(2n-1). - Antti Karttunen, Feb 26 2014
EXAMPLE
Triangular number nearest to 2^8=256 is 253, so a(8)=256-253=3.
MATHEMATICA
a[n_] := Module[{k, k0}, k0 = k /. FindRoot[2^n == k*(k+1)/2, {k, 2^(n/2)}, WorkingPrecision -> 20] // Round; Abs[2^n-k0*(k0+1)/2]]; Table[a[n], {n, 0, 46}] (* Jean-François Alcover, Feb 27 2014 *)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Alex Ratushnyak, Feb 23 2014
STATUS
approved