login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A238455 Difference between 4^n and the nearest triangular number. 2
0, 1, 1, -2, 3, -11, 1, -87, -167, -306, -500, -552, 688, -3041, -579, 20854, 37075, 55618, 37108, -222296, -147729, 891994, 602155, -3523022, -2228805, 14811346, 11792251, -47737262, -1136517, 375078994, 741065851, 1445763154, 2746052116, 4910207464, 7492827856 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,4

LINKS

Harvey P. Dale, Table of n, a(n) for n = 0..1000

EXAMPLE

a(0) = 1 - 1 = 0.

a(1) = 4 - 3 = 1.

a(2) = 16 - 15 = 1.

a(3) = 64 - 66 = -2.

a(4) = 256 - 253 = 3.

MATHEMATICA

db4n[n_]:=Module[{c=4^n, tr, t1, t2, d1, d2}, tr=Floor[(Sqrt[8c+1]-1)/2]; t1= (tr (tr+1))/ 2; t2=((tr+1)(tr+2))/2; d1=c-t1; d2=c-t2; If[d1<Abs[ d2], d1, d2]]; Array[ db4n, 40, 0] (* Harvey P. Dale, Jul 02 2019 *)

PROG

(Python)

def isqrt(a):

    sr = 1L << (long.bit_length(long(a)) >> 1)

    while a < sr*sr:  sr>>=1

    b = sr>>1

    while b:

        s = sr + b

        if a >= s*s:  sr = s

        b>>=1

    return sr

for n in range(77):

    nn = 4**n

    s = isqrt(2*nn)

    if s*(s+1)/2 > nn:  s-=1

    d1 = nn - s*(s+1)/2

    d2 = (s+1)*(s+2)/2 - nn

    if d2 < d1:  d1 = -d2

    print str(d1)+', ',

(PARI) a(n) = {pow = 4^n; ft = floor((sqrt(8*pow+1) - 1)/2); df = pow - ft*(ft+1)/2; dc = pow - (ft+1)*(ft+2)/2; if (abs(df) > abs(dc), dc, df); } \\ Michel Marcus, Feb 27 2014

CROSSREFS

Absolute values give the other bisection of A233327.

Cf. A000079, A000217.

Sequence in context: A070239 A002443 A111788 * A098929 A073098 A201267

Adjacent sequences:  A238452 A238453 A238454 * A238456 A238457 A238458

KEYWORD

sign

AUTHOR

Alex Ratushnyak, Feb 26 2014

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 5 10:28 EDT 2020. Contains 333239 sequences. (Running on oeis4.)