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.

Showing 1-4 of 4 results.

A117074 Number at start of segment n of A117073.

Original entry on oeis.org

1, 4, 9, 20, 40, 82, 166, 334, 670, 1340, 2682, 5366, 10734, 21470, 42942, 85886, 171774
Offset: 1

Views

Author

N. J. A. Sloane, Apr 17 2006

Keywords

References

  • N. J. A. Sloane and Allan Wilks, On sequences of Recaman type, paper in preparation, 2006.

A117075 Number at end of segment n of A117073.

Original entry on oeis.org

3, 6, 11, 22, 42, 84, 168, 336, 672, 1342, 2684, 5368, 10736, 21472, 42944, 85888, 171776
Offset: 1

Views

Author

N. J. A. Sloane, Apr 18 2006

Keywords

References

  • N. J. A. Sloane and Allan Wilks, On sequences of Recaman type, paper in preparation, 2006.

Crossrefs

Equals A117074(n) + 2.

A078783 a(0) = 0; a(1)=1; for n>1, a(n) = least positive integer m not among a(1),...,a(n-1) such that |m-a(n-1)| > |a(n-1)-a(n-2)|.

Original entry on oeis.org

0, 1, 3, 6, 2, 7, 13, 4, 14, 25, 5, 26, 48, 8, 49, 91, 9, 92, 176, 10, 177, 345, 11, 346, 682, 12, 683, 1355, 15, 1356, 2698, 16, 2699, 5383, 17, 5384, 10752, 18, 10753, 21489, 19, 21490, 42962, 20, 42963, 85907, 21, 85908, 171796, 22, 171797
Offset: 0

Views

Author

Reiner Martin, Jan 09 2003

Keywords

Comments

This is a permutation pi of the nonnegative integers such that |pi(n+1)-pi(n)| is strictly increasing. In other words, it is a walk on the nonnegative numbers with strictly increasing step size which visits every number exactly once.
A greedy version of Recamán's sequence: Construct two sequences a() and d() as follows. a(0)=0, a(1)=1, a(2)=3, d(0)=0, d(1)=1, d(2)=2. For n>=3, let m be smallest nonnegative number not yet in the a sequence. Let i = a(n-1)-m. If i > d(n), then a(n) = a(n-1)-i = m, d(n) = i; otherwise a(n) = a(n-1)+d(n-1)+1, d(n) = d(n-1)+1. Has the properties that a() is the Recamán transform of d() and every number appears in a(). This sequence is a(), while d() is A117073. Has a natural decompostion into segments of length 3. - N. J. A. Sloane, Apr 16 2006
For n>0: a(3*n-2)=A117070(n), a(3*n-1)=A117071(n) and a(3*n)=A117072(n).

References

  • N. J. A. Sloane and Allan Wilks, On sequences of Recaman type, paper in preparation, 2006.

Crossrefs

Cf. A257502 (inverse).

Programs

  • Haskell
    import Data.List (delete)
    a078783 n = a078783_list !! n
    (a078783_list, a117073_list) = unzip $
       (0,0) : (1,1) : (3,2) : f 3 2 (2:[4..]) where
       f a d ms@(m:_) = (a', d') : f a' d' (delete a' ms) where
         (a', d') = if i > d then (m, i) else (a + d + 1, d + 1)
         i = a - m
    -- Reinhard Zumkeller, May 01 2015
  • Mathematica
    a[0] = 0; a[1] = 1;
    a[n_] := a[n] = For[m = 2, True, m++, If[FreeQ[Array[a, n-1], m], If[Abs[m - a[n-1]] > Abs[a[n-1] - a[n-2]], Return[m]]]];
    Table[a[n], {n, 0, 50}] (* Jean-François Alcover, Aug 02 2018 *)

A064365 a(0) = 0; thereafter a(n) = a(n-1)-prime(n) if positive and new, otherwise a(n) = a(n-1)+prime(n), where prime(n) is the n-th prime.

Original entry on oeis.org

0, 2, 5, 10, 3, 14, 1, 18, 37, 60, 31, 62, 25, 66, 23, 70, 17, 76, 15, 82, 11, 84, 163, 80, 169, 72, 173, 276, 383, 274, 161, 34, 165, 28, 167, 316, 467, 310, 147, 314, 141, 320, 139, 330, 137, 334, 135, 346, 123, 350, 121, 354, 115, 356, 105, 362, 99, 368, 97, 374, 93
Offset: 0

Views

Author

Neil Fernandez, Sep 25 2001

Keywords

Comments

'Recamán transform' (see A005132) of the prime sequence. Note that the definition permits repeated terms [though only by addition] (and there are many repeated terms, just as there are in A005132).
Does every positive integer appear in the sequence? This seems unlikely, since 4 has not appeared in 70000 terms.
Note: this is similar to Clark Kimberling's A022831, except in the latter sequence the words 'and new' have been omitted.
The smallest numbers not occurring in the first million terms: 4, 6, 7, 12, 13, 16, 19, 20, 21, 22, 24, 26, 27, 29, 30, 32, 36, 39, 41, 42. - Reinhard Zumkeller, Apr 26 2012

Examples

			To find a(9) we try subtracting the 9th prime, which is 23, from a(8), which is 37. 37 - 23 = 14, but 14 is already in the sequence (it is a(5)), so we must add. a(9) = 37 + 23 = 60.
		

Crossrefs

Programs

  • Haskell
    import Data.Set (singleton, notMember, insert)
    a064365 n = a064365_list !! n
    a064365_list = 0 : f 0 a000040_list (singleton 0) where
       f x (p:ps) s | x' > 0 && x' `notMember` s = x' : f x' ps (insert x' s)
                    | otherwise                  = xp : f xp ps (insert xp s)
                    where x' = x - p; xp = x + p
    -- Reinhard Zumkeller, Apr 26 2012
    
  • Mathematica
    a = {0}; Do[ If[ a[ [ -1 ] ] - Prime[ n ] > 0 && Position[ a, a[ [ -1 ] ] - Prime[ n ] ] == {}, a = Append[ a, a[ [ -1 ] ] - Prime[ n ] ], a = Append[ a, a[ [ -1 ] ] + Prime[ n ] ] ], {n, 1, 70} ]; a (* Modified by Ivan N. Ianakiev, Aug 05 2019, to accommodate the new initial term of a(0). *)
  • PARI
    A064365(N,s/*=1 to print all terms*/)={ my(a=0,u=0); N & forprime(p=1,prime(N), s & print1(a","); u=bitor(u,2^a+=if(a<=p || bittest(u,a-p),p,-p)));a}  \\ M. F. Hasler, Mar 07 2012
    
  • Python
    from sympy import primerange, prime
    def aupton(terms):
      alst = [0]
      for n, pn in enumerate(primerange(1, prime(terms)+1), start=1):
        x = alst[-1] - pn
        alst += [x if x > 0 and x not in alst else alst[-1] + pn]
      return alst
    print(aupton(60)) # Michael S. Branicky, May 30 2021

Formula

a(n) = A117128(n) - 1. - Thomas Ordowski, Dec 05 2016

Extensions

More terms from Robert G. Wilson v, Sep 26 2001
Further terms from N. J. A. Sloane, Feb 10 2002
Added initial term a(0)=0, in analogy with A128204, A005132, A053461, A117073/A078783. - M. F. Hasler, Mar 07 2012
Showing 1-4 of 4 results.