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-2 of 2 results.

A057167 Term in Recamán's sequence A005132 where n appears for first time, or -1 if n never appears.

Original entry on oeis.org

0, 1, 4, 2, 131, 129, 3, 5, 16, 14, 12, 10, 8, 6, 31, 29, 27, 25, 23, 99734, 7, 9, 11, 13, 15, 17, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 111, 22, 20, 18, 28, 30, 32, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196
Offset: 0

Views

Author

N. J. A. Sloane, Sep 14 2000

Keywords

Crossrefs

Programs

  • Maple
    w := array(1..10000); for j from 1 to 100 do l := 0; for k from 1 to nops(a) do if a[k] = j then l := k; exit; fi; od: w[j] := l; od: s := [seq(w[j],j=1..100)]; # where a is an array formed from sequence A005132
  • Mathematica
    A005132 = {0}; Do[If[(r = Last[A005132] - n) <= 0 || MemberQ[ A005132, r], r = r + 2n]; AppendTo[ A005132, r], {n, 1, 10^5}]; a[n_] := If[p = Position[ A005132, n]; p == {}, 0, p[[1, 1]] - 1]; Table[a[n], {n, 1, 60}] (* Jean-François Alcover, Jul 18 2012 *)
  • PARI
    first(n) = my(a=vector(n), r=[0]); while(#Set(a)Iain Fox, Jul 11 2022
    
  • Python
    from itertools import count, islice
    def agen(): # generator of terms
        an, A005132set, inv, y = 0, {0}, {0: 0}, 0
        for n in count(1):
            t = an - n
            an = t if t >= 0 and t not in A005132set else an + n
            A005132set.add(an)
            inv[an] = n
            while y in inv: yield inv[y]; y += 1
    print(list(islice(agen(), 61))) # Michael S. Branicky, Jul 12 2022

Extensions

I conjecture a(n) is never -1 - but see A064227, A064228.
a(0)=0 added and escape clause value changed to -1 by N. J. A. Sloane, May 01 2020

A187922 Positions k of addition steps in Recamán's sequence where A005132(k-1)-k = A005132(m) for some 0 < m < k.

Original entry on oeis.org

6, 7, 9, 18, 19, 21, 33, 34, 36, 66, 67, 69, 71, 73, 75, 101, 102, 104, 106, 108, 113, 114, 115, 117, 121, 123, 125, 127, 133, 134, 172, 173, 175, 177, 179, 181, 183, 186, 188, 189, 190, 194, 224, 225, 227, 229, 231, 233, 236, 238, 240, 242, 244, 246, 287, 288, 290, 292, 294, 296, 298, 300, 302, 304, 339, 340, 342, 344, 346, 348, 350
Offset: 1

Views

Author

Reinhard Zumkeller, Mar 17 2011

Keywords

Comments

Subsequence of A057165; A005132(a(n)-1) - a(n) = A005132(A187943(n));
A005132(a(n)) = A005132(a(n)-1) + a(n);
See A187921 for the other positions of addition steps in A005132.

Examples

			a(5) = 19: A005132(19-1) = 43 and 43-19>0, but the term 24=43-19 is already in A005132, therefore A005132(19)=43+19=62; A187943(5)=15 and A005132(15)=24.
		

Crossrefs

Programs

  • Haskell
    import Data.Set (Set, singleton, member, insert)
    a187922 n = a187922_list !! (n-1)
    a187922_list = r (singleton 0) 1 0 where
       r :: Set Integer -> Integer -> Integer -> [Integer]
       r s n x | x <= n           = r (insert (x+n) s) (n+1) (x+n)
               | (x-n) `member` s = n : r (insert (x+n) s) (n+1) (x+n)
               | otherwise        = r (insert (x-n) s) (n+1) (x-n)
    (C++) See Links section.

Extensions

Added condition "0 < m" to definition. See A333552. - N. J. A. Sloane, May 04 2020
Showing 1-2 of 2 results.