login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A076042 a(0) = 0; thereafter a(n) = a(n-1) + n^2 if a(n-1) < n^2 else a(n) = a(n-1) - n^2. 11
0, 1, 5, 14, 30, 5, 41, 90, 26, 107, 7, 128, 272, 103, 299, 74, 330, 41, 365, 4, 404, 845, 361, 890, 314, 939, 263, 992, 208, 1049, 149, 1110, 86, 1175, 19, 1244, 2540, 1171, 2615, 1094, 2694, 1013, 2777, 928, 2864, 839, 2955, 746, 3050, 649, 3149 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

COMMENTS

Does not return to zero within first 2^25000 =~ 10^7525 terms.  Define an epoch as an addition followed by a sequence of (addition, subtraction) pairs.  The first epoch has length 1 (+), the second 3 (++-), the third 5 (++-+-), and so forth (cf. A324792).  The epoch lengths increase geometrically by about the square root of 3, and the value at the end of each epoch is the low value in the epoch.  These observations lead to the Python program given. - Tomas Rokicki, Aug 31 2019

Using the Maple program in A324791, I confirmed that a(n) != 0 for 0 < n < 10^2394. See the a- and b-files in A325056 and A324791. - N. J. A. Sloane, Oct 03 2019

LINKS

Tomas Rokicki, Table of n, a(n) for n = 0..20000

PROG

(PARI) v=vector(50); v[1]=1; for(n=2, 50, if(v[n-1]<n^2, v[n]=v[n-1]+n^2, v[n]=v[n-1]-n^2)); print(v)

(Python)

(b, sq, inc, t) = (1, 4, 5, 1)

while True:

   print t, b

   if b == 0 or b == sq:

      print "Got to Zero"

      exit(10)

   elif b > inc:

      n = 1

      while n * (inc + 2 * n - 2) <= b: n = n * 2

      n = n // 2

      bb = n // 2

      while bb > 0:

         if (n + bb) * (inc + 2 * (n + bb) - 2) <= b: n = n + bb

         bb = bb // 2

      b -= n * (inc + 2 * n - 2)

      sq += 2 * n * inc + 2 * n * (2 * n - 1)

      (inc, t) = (inc + 4*n, t+2*n)

   else:

      (b, sq, inc, t) = (b+sq, sq+inc, inc+2, t+1)

CROSSREFS

Cf. A076039, A003462, A076041, A046901.

See also A325056, A324791, A324792.

Sequence in context: A019262 A212919 A280230 * A231669 A256986 A162208

Adjacent sequences:  A076039 A076040 A076041 * A076043 A076044 A076045

KEYWORD

nonn

AUTHOR

Amarnath Murthy, Oct 29 2002

EXTENSIONS

More terms from Ralf Stephan, Mar 20 2003

Prepended a(0)=0 at the suggestion of Allan C. Wechsler. - N. J. A. Sloane, Aug 31 2019

Setting offset to 0 to cohere with previous action of N. J. A. Sloane. - Allan C. Wechsler, Sep 08 2019

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 October 22 22:34 EDT 2019. Contains 328335 sequences. (Running on oeis4.)