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.

Previous Showing 11-20 of 51 results. Next

A308013 List of y-coordinates of successive points on the middle one of the three lines formed by the terms of A081145.

Original entry on oeis.org

1, 2, 4, 8, 12, 16, 21, 25, 28, 33, 37, 42, 45, 48, 55, 58, 61, 66, 71, 75, 78, 81, 87, 91, 96, 100, 102, 108, 110, 114, 120, 124, 127, 131, 134, 139, 143, 148, 153, 156, 160, 164, 168, 172, 176, 180, 185, 189, 194, 198, 202, 206, 209, 212, 215, 220, 224
Offset: 1

Views

Author

N. J. A. Sloane, May 15 2019

Keywords

Comments

See A081145 and A308009 for further information about the three lines.

Crossrefs

A084332 Duplicate of A081145.

Original entry on oeis.org

1, 2, 4, 7, 3, 8, 14, 5, 12, 20, 6, 16, 27, 9, 21, 34, 10, 25, 41, 11, 28, 47, 13, 33, 54, 15
Offset: 0

Views

Author

Keywords

A005228 Sequence and first differences (A030124) together list all positive numbers exactly once.

Original entry on oeis.org

1, 3, 7, 12, 18, 26, 35, 45, 56, 69, 83, 98, 114, 131, 150, 170, 191, 213, 236, 260, 285, 312, 340, 369, 399, 430, 462, 495, 529, 565, 602, 640, 679, 719, 760, 802, 845, 889, 935, 982, 1030, 1079, 1129, 1180, 1232, 1285, 1339, 1394, 1451, 1509, 1568, 1628, 1689
Offset: 1

Views

Author

Keywords

Comments

This is the lexicographically earliest sequence that together with its first differences (A030124) contains every positive integer exactly once.
Hofstadter introduces this sequence in his discussion of Scott Kim's "FIGURE-FIGURE" drawing. - N. J. A. Sloane, May 25 2013
A225850(a(n)) = 2*n-1, cf. A167151. - Reinhard Zumkeller, May 17 2013
In view of the definition of A075326: start with a(0) = 0, and extend by rule that the next term is the sum of the predecessor and the most recent non-member of the sequence. - Reinhard Zumkeller, Oct 26 2014

Examples

			Sequence reads 1 3 7 12 18 26 35 45..., differences are 2 4 5, 6, 8, 9, 10 ... and the point is that every number not in the sequence itself appears among the differences. This property (together with the fact that both the sequence and the sequence of first differences are increasing) defines the sequence!
		

References

  • E. Angelini, "Jeux de suites", in Dossier Pour La Science, pp. 32-35, Volume 59 (Jeux math'), April/June 2008, Paris.
  • D. R. Hofstadter, Goedel, Escher, Bach: an Eternal Golden Braid, Random House, 1980, p. 73.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A030124 (complement), A037257, A056731, A056738, A140778, A225687.
Cf. A225850, A232746, A232747 (inverse), A232739, A232740, A232750 and also permutation pair A232751/A232752 constructed from this sequence and its complement.
Cf. A001651 (analog with sums instead of differences), A121229 (analog with products).
The same recurrence a(n) = a(n-1) + c(n-1) with different starting conditions: A061577 (starting with 2), A022935 (3), A022936 (4), A022937 (5), A022938 (6).
Related recurrences:
a(n-1) + c(n+1) - A022953, A022954.
a(n-1) + c(n) - A022946 to A022952.
a(n-1) + c(n-2) - A022940, A022941.
a(n-2) + c(n-1) - A022942 to A022944.
a(n-2) + c(n-2) - A022939.
a(n-3) + c(n-3) - A022955.
a(n-4) + c(n-4) - A022956.
a(n-5) + c(n-5) - A022957.

Programs

  • Haskell
    a005228 = scanl (+) 1 a030124
    a030124 = go 1 a005228 where go x ys | x < head ys = x     : go (x + 1) ys
                                         | otherwise   = x + 1 : go (x + 2) (tail ys)
    -- Maks Verver, Jun 30 2025
    
  • Maple
    maxn := 5000; h := array(1..5000); h[1] := 1; a := [1]; i := 1; b := []; for n from 2 to 1000 do if h[n] <> 1 then b := [op(b), n]; j := a[i]+n; if j < maxn then a := [op(a),j]; h[j] := 1; i := i+1; fi; fi; od: a; b; # a is A005228, b is A030124.
    A030124 := proc(n)
        option remember;
        local a,fnd,t ;
        if n <= 1 then
            op(n+1,[2,4]) ;
        else
            for a from procname(n-1)+1 do
                fnd := false;
                for t from 1 to n+1 do
                    if A005228(t)  = a then
                        fnd := true;
                        break;
                    end if;
                end do:
                if not fnd then
                    return a;
                end if;
            end do:
        end if;
    end proc:
    A005228 := proc(n)
        option remember;
        if n <= 2 then
            op(n,[1,3]) ;
        else
            procname(n-1)+A030124(n-2) ;
        end if;
    end proc: # R. J. Mathar, May 19 2013
  • Mathematica
    a = {1}; d = 2; k = 1; Do[ While[ Position[a, d] != {}, d++ ]; k = k + d; d++; a = Append[a, k], {n, 1, 55} ]; a
    (* Second program: *)
    (* Program from Larry Morris, Jan 19 2017: *)
    d = 3; a = {1, 3, 7, 12, 18}; While[ Length[a = Join[a, a[[-1]] + Accumulate[Range[a[[d]] + 1, a[[++d]] - 1]]]] < 50]; a
    (* Comment: This adds as many terms to the sequence as there are numbers in each set of sequential differences. Consequently, the list of numbers it produces may be longer than the limit provided. With the limit of 50 shown, the sequence produced has length 60. *)
  • PARI
    A005228(n,print_all=0,s=1,used=0)={while(n--,used += 1<M. F. Hasler, Feb 05 2013

Formula

a(n) = a(n-1) + c(n-1) for n >= 2, where a(1)=1, a( ) increasing, c( ) = complement of a( ) (c is the sequence A030124).
Let a(n) = this sequence, b(n) = A030124 prefixed by 0. Then b(n) = mex{ a(i), b(i) : 0 <= i < n}, a(n) = a(n-1) + b(n) + 1. (Fraenkel)
a(1) = 1, a(2) = 3; a( ) increasing; for n >= 3, if a(q) = a(n-1)-a(n-2)+1 for some q < n then a(n) = a(n-1) + (a(n-1)-a(n-2)+2), otherwise a(n) = a(n-1) + (a(n-1)-a(n-2)+1). - Albert Neumueller (albert.neu(AT)gmail.com), Jul 29 2006
a(n) = n^2/2 + n^(3/2)/(3*sqrt(2)) + O(n^(5/4)) [proved in Jubin link]. - Benoit Jubin, May 13 2015
For all n >= 1, A232746(a(n)) = n and A232747(a(n)) = n. [Both sequences work as left inverses of this sequence.] - Antti Karttunen, May 14 2015

Extensions

Additional comments from Robert G. Wilson v, Oct 24 2001
Incorrect formula removed by Benoit Jubin, May 13 2015

A030124 Complement (and also first differences) of Hofstadter's sequence A005228.

Original entry on oeis.org

2, 4, 5, 6, 8, 9, 10, 11, 13, 14, 15, 16, 17, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 70, 71, 72, 73, 74, 75, 76, 77, 78
Offset: 1

Views

Author

Keywords

Comments

For any n, all integers k satisfying sum(i=1,n,a(i))+1Benoit Cloitre, Apr 01 2002
The asymptotic equivalence a(n) ~ n follows from the fact that the values disallowed in the present sequence because they occur in A005228 are negligible, since A005228 grows much faster than A030124. The next-to-leading term in the formula is calculated from the functional equation F(x) + G(x) = x, suggested by D. Wilson (cf. reference), where F and G are the inverse functions of smooth, increasing approximations f and f' of A005228 and A030124. It seems that higher order corrections calculated from this equation do not agree with the real behavior of a(n). - M. F. Hasler, Jun 04 2008
A225850(a(n)) = 2*n, cf. A167151. - Reinhard Zumkeller, May 17 2013

References

  • E. Angelini, "Jeux de suites", in Dossier Pour La Science, pp. 32-35, Volume 59 (Jeux math'), April/June 2008, Paris.
  • D. R. Hofstadter, "Gödel, Escher, Bach: An Eternal Golden Braid", Basic Books, 1st & 20th anniv. edition (1979 & 1999), p. 73.

Crossrefs

Programs

  • Haskell
    import Data.List (delete)
    a030124 n = a030124_list !! n
    a030124_list = figureDiff 1 [2..] where
       figureDiff n (x:xs) = x : figureDiff n' (delete n' xs) where n' = n + x
    -- Reinhard Zumkeller, Mar 03 2011
  • Mathematica
    (* h stands for Hofstadter's sequence A005228 *) h[1] = 1; h[2] = 3; h[n_] := h[n] = 2*h[n-1] - h[n-2] + If[ MemberQ[ Array[h, n-1], h[n-1] - h[n-2] + 1], 2, 1]; Differences[ Array[h, 69]] (* Jean-François Alcover, Oct 06 2011 *)
  • PARI
    {a=b=t=1;for(i=1,100, while(bittest(t,b++),); print1(b",");t+=1<M. F. Hasler, Jun 04 2008
    

Formula

a(n) = n + sqrt(2n) + o(n^(1/2)). - M. F. Hasler, Jun 04 2008 [proved in Jubin's paper].

Extensions

Changed offset to agree with that of A005228. - N. J. A. Sloane, May 19 2013

A175498 a(1)=1. a(n) = the smallest positive integer not occurring earlier such that a(n)-a(n-1) doesn't equal a(k)-a(k-1) for any k with 2 <= k <= n-1.

Original entry on oeis.org

1, 2, 4, 3, 6, 10, 5, 11, 7, 12, 9, 16, 8, 17, 15, 23, 13, 24, 18, 28, 14, 26, 19, 32, 20, 34, 21, 36, 25, 41, 22, 39, 30, 48, 27, 46, 29, 49, 31, 52, 37, 59, 33, 56, 40, 64, 35, 60, 38, 65, 42, 68, 43, 71, 44, 73, 45, 75, 51, 82, 47, 79, 112, 50, 84, 53, 88, 54, 90, 57, 94, 55, 93, 61, 100, 58, 98, 62, 103, 63, 105, 67
Offset: 1

Views

Author

Leroy Quet, May 31 2010

Keywords

Comments

This sequence is a permutation of the positive integers.
a(n+1)-a(n) = A175499(n).
Conjecture: the lexicographically earliest permutation of {1,2,...n} for which differences of adjacent numbers are all distinct (cf. A131529) has, for n-->infinity, this sequence as its prefix. - Joerg Arndt, May 27 2012

Crossrefs

Programs

  • Haskell
    import Data.List (delete)
    a175498 n = a175498_list !! (n-1)
    a175498_list = 1 : f 1 [2..] [] where
       f x zs ds = g zs where
         g (y:ys) | diff `elem` ds = g ys
                  | otherwise      = y : f y (delete y zs) (diff:ds)
                  where diff = y - x
    -- Reinhard Zumkeller, Apr 25 2015
  • Mathematica
    a[1] = 1; d[1] = 0; k = 1; z = 10000; zz = 120;
    A[k_] := Table[a[i], {i, 1, k}]; diff[k_] := Table[d[i], {i, 1, k}];
    c[k_] := Complement[Range[-z, z], diff[k]];
    T[k_] := -a[k] + Complement[Range[z], A[k]];
    Table[{h = Min[Intersection[c[k], T[k]]], a[k + 1] = a[k] + h, d[k + 1] = h, k = k + 1}, {i, 1, zz}];
    u = Table[a[k], {k, 1, zz}]  (* Clark Kimberling, May 13 2015 *)
  • Python
    A175498_list, l, s, b1, b2 = [1,2], 2, 3, set(), set([1])
    for n in range(3, 10**5):
        i = s
        while True:
            if not (i in b1 or i-l in b2):
                A175498_list.append(i)
                b1.add(i)
                b2.add(i-l)
                l = i
                while s in b1:
                    b1.remove(s)
                    s += 1
                break
            i += 1 # Chai Wah Wu, Dec 15 2014
    

Extensions

More terms from Sean A. Irvine, Jan 27 2011

A257883 Sequence (a(n)) generated by Algorithm (in Comments) with a(1) = 0 and d(1) = 0.

Original entry on oeis.org

0, 1, 3, 2, 5, 9, 4, 10, 6, 11, 8, 15, 7, 16, 14, 22, 12, 23, 17, 27, 13, 25, 18, 31, 19, 33, 20, 35, 24, 40, 21, 38, 29, 47, 26, 45, 28, 48, 30, 51, 36, 58, 32, 55, 39, 63, 34, 59, 37, 64, 41, 67, 42, 70, 43, 72, 44, 74, 50, 81, 46, 78, 111, 49, 83, 52, 87
Offset: 1

Views

Author

Clark Kimberling, May 13 2015

Keywords

Comments

Algorithm: For k >= 1, let A(k) = {a(1), ..., a(k)} and D(k) = {d(1), ..., d(k)}. Begin with k = 1 and nonnegative integers a(1) and d(1). Let h be the least integer > -a(k) such that h is not in D(k) and a(k) + h is not in A(k). Let a(k+1) = a(k) + h and d(k+1) = h. Replace k by k+1 and repeat inductively.
Conjecture: if a(1) is a nonnegative integer and d(1) is an integer, then (a(n)) is a permutation of the nonnegative integers (if a(1) = 0) or a permutation of the positive integers (if a(1) > 0). Moreover, (d(n)) is a permutation of the integers if d(1) = 0, or of the nonzero integers if d(1) > 0.
Guide to related sequences:
a(1) d(1) (a(n)) (d(n))
0 0 A257883 A175499 except for initial terms
1 0 A175498 A175499 except for first term
2 1 A257910 A257909 except for initial terms

Examples

			a(1) = 0, d(1) = 0;
a(2) = 1, d(2) = 1;
a(3) = 3, d(3) = 2;
a(4) = 2, d(4) = -1.
		

Crossrefs

Programs

  • Mathematica
    a[1] = 0; d[1] = 0; k = 1; z = 10000; zz = 120;
    A[k_] := Table[a[i], {i, 1, k}]; diff[k_] := Table[d[i], {i, 1, k}];
    c[k_] := Complement[Range[-z, z], diff[k]];
    T[k_] := -a[k] + Complement[Range[z], A[k]]
    Table[{h = Min[Intersection[c[k], T[k]]], a[k + 1] = a[k] + h,
       d[k + 1] = h, k = k + 1}, {i, 1, zz}];
    u = Table[a[k], {k, 1, zz}]  (* A257883, = -1 + A175498 *)
    Table[d[k], {k, 1, zz}] (* A175499 except that here first term is 0 *)

Formula

a(k+1) - a(k) = d(k+1) for k >= 1.
Also, A257883(n) = -1 + A175498(n) for n >= 1.

A257705 Sequence (a(n)) generated by Rule 1 (in Comments) with a(1) = 0 and d(1) = 0.

Original entry on oeis.org

0, 1, 3, 2, 5, 9, 7, 4, 10, 6, 11, 18, 13, 21, 15, 8, 17, 27, 19, 30, 20, 32, 23, 12, 25, 39, 26, 14, 29, 45, 31, 16, 33, 51, 35, 54, 37, 57, 38, 59, 41, 63, 43, 22, 46, 24, 47, 72, 49, 75, 50, 77, 53, 81, 55, 28, 58, 87, 56, 88, 60, 91, 62, 95, 65, 99, 67
Offset: 1

Views

Author

Clark Kimberling, May 12 2015

Keywords

Comments

Rule 1 follows. For k >= 1, let A(k) = {a(1), …, a(k)} and D(k) = {d(1), …, d(k)}. Begin with k = 1 and nonnegative integers a(1) and d(1).
Step 1: If there is an integer h such that 1 - a(k) < h < 0 and h is not in D(k) and a(k) + h is not in A(k), let d(k+1) be the greatest such h, let a(k+1) = a(k) + h, replace k by k + 1, and repeat Step 1; otherwise do Step 2.
Step 2: Let h be the least positive integer not in D(k) such that a(k) + h is not in A(k). Let a(k+1) = a(k) + h and d(k+1) = h. Replace k by k+1 and do Step 1.
Conjecture: if a(1) is an nonnegative integer and d(1) is an integer, then (a(n)) is a permutation of the nonnegative integers (if a(1) = 0) or a permutation of the positive integers (if a(1) > 0). Moreover, (d(n)) is a permutation of the integers if d(1) = 0, or of the nonzero integers if d(1) > 0.
Guide to related sequences:
a(1) d(1) (a(n)) (d(n))
0 0 A257705 A131389 except for initial terms
0 1 A257706 A131389 except for initial terms
0 2 A257876 A131389 except for initial terms
1 1 A257878 A131389 except for initial terms
2 1 A257881 A257880 except for initial terms

Examples

			a(2) = a(1) + d(2) = 0 + 1 = 1;
a(3) = a(2) + d(3) = 1 + 2 = 3;
a(4) = a(3) + d(4) = 3 + (-1) = 2.
		

Crossrefs

Programs

  • Mathematica
    a[1] = 0; d[1] = 0; k = 1; z = 10000; zz = 120;
    A[k_] := Table[a[i], {i, 1, k}]; diff[k_] := Table[d[i], {i, 1, k}];
    c[k_] := Complement[Range[-z, z], diff[k]];
    T[k_] := -a[k] + Complement[Range[z], A[k]];
    s[k_] := Intersection[Range[-a[k], -1], c[k], T[k]];
    Table[If[Length[s[k]] == 0, {h = Min[Intersection[c[k], T[k]]], a[k + 1] = a[k] + h, d[k + 1] = h, k = k + 1}, {h = Max[s[k]], a[k + 1] = a[k] + h, d[k + 1] = h, k = k + 1}], {i, 1, zz}];
    u = Table[a[k], {k, 1, zz}] (* A257705 *)
    Table[d[k], {k, 1, zz}]     (* A131389 *)

Formula

a(k+1) - a(k) = d(k+1) for k >= 1.
Also, a(k) = A131388(n)-1.

A100707 a(1) = 1; for n > 1, a(n+1)=a(n)-k if there exists a positive number k (take the smallest) that has not yet been used and is such that a(n+1) is new and >0, otherwise a(n+1) = a(n)+k if the same conditions are satisfied.

Original entry on oeis.org

1, 2, 4, 7, 3, 8, 14, 6, 13, 22, 12, 23, 11, 24, 10, 25, 9, 26, 5, 27, 45, 21, 40, 20, 43, 18, 44, 17, 46, 16, 47, 19, 51, 15, 48, 82, 42, 77, 39, 76, 37, 78, 36, 79, 35, 80, 34, 81, 33, 83, 32, 84, 31, 85, 30, 86, 29, 87, 38, 97, 28, 88, 149, 75, 137, 74
Offset: 1

Views

Author

Keywords

Comments

A sequence of distinct natural numbers with the property that absolute successive differences are distinct.
A more long-winded definition: start with a(1) = 1. We keep a list of the numbers k that have been used as differences so far; initially this list is empty. Each difference can be used at most once.
Suppose a(n) = M. To get a(n+1), we subtract from M each number k < M that has not yet been used, starting from the smallest. If for any such k, M-k is a number not yet in the sequence, set a(n+1) = M-k and mark the difference k as used.
If no k works, then we add each number k that has not yet been used to M, again starting with the smallest. When we find a k such that M+k is a number not yet in the sequence, we set a(n+1) = M+k and mark k as used. Repeat.
The main question is: does every number appear in the sequence?
A227617(n) = smallest m such that a(m) = n: if this sequence is a permutation of the natural numbers, then A227617 is its inverse. - Reinhard Zumkeller, Jul 19 2013

Examples

			1 -> 1+1 = 2 and k=1 has been used as a difference.
2 -> 2+4 = 4 and k=2 has been used as a difference.
4 could go to 4-3 = 1, except that 1 has already appeared in the sequence; so 4 -> 4+3 = 7 and k=3 has been used as a difference.
7 -> 7-4 = 3 (for the first time we can subtract) and k=4 has been used as a difference. And so on.
		

Crossrefs

Similar to Murthy's sequence A093903, Cald's sequence (A006509) and Recamán's sequence A005132. See also A081145, A100709 (another version). Cf. A100708 (the successive differences associated with this sequence).

Programs

  • Haskell
    import Data.List (delete)
    import qualified Data.Set as Set (insert)
    import Data.Set (singleton, member)
    a100707 n = a100707_list !! (n-1)
    a100707_list = 1 : f 1 (singleton 1) [1..] where
       f y st ds = g ds where
         g (k:ks) | v <= 0      = h ds
                  | member v st = g ks
                  | otherwise   = v : f v (Set.insert v st) (delete k ds)
                  where v = y - k
         h (k:ks) | member w st = h ks
                  | otherwise   = w : f w (Set.insert w st) (delete k ds)
                  where w = y + k
    -- Reinhard Zumkeller, Jul 19 2013

Extensions

Data corrected for n > 46 by Reinhard Zumkeller, Jul 19 2013

A257218 Lexicographically earliest sequence of distinct positive integers such that gcd(a(n), a(n-1)) takes no value more than twice.

Original entry on oeis.org

1, 2, 3, 6, 4, 8, 10, 5, 15, 9, 18, 12, 16, 24, 30, 20, 40, 32, 48, 36, 27, 54, 72, 60, 45, 75, 25, 50, 70, 7, 14, 28, 42, 21, 63, 126, 84, 56, 112, 64, 96, 120, 80, 100, 150, 90, 108, 81, 162, 216, 144, 168, 140, 35, 105, 210, 180, 135, 225, 300
Offset: 1

Views

Author

Ivan Neretin, Apr 18 2015

Keywords

Comments

Presumably a(n) is a permutation of the positive integers.
Primes seem to occur in their natural order. 31 appears as a(7060). Primes p >= 37 are not found among the first 10000 terms.
Numbers n such that a(n)=n are 1, 2, 3, 12, 306, ...
A256918(n) = gcd(a(n), a(n+1)); gcd(a(A257120(n)), a(A257120(n)+1)) = gcd(a(A257475(n)), a(A257475(n)-1)) = n. - Reinhard Zumkeller, Apr 25 2015
For p prime: A257122(p)-1 = index of the smallest multiple of p: a(A257122(p)-1) mod p = 0 and a(m) mod p > 0 for m < A257122(p)-1. - Reinhard Zumkeller, Apr 26 2015

Examples

			After a(9)=15, the values 1, 2, 3, 4, 6, and 8 are already used, while 7 is forbidden because gcd(15,7)=1 and that value of GCD has already occurred twice, at (1,2) and (2,3). The minimal value which is neither used not forbidden is 9, so a(10)=9.
		

Crossrefs

Other minimal sequences of distinct positive integers that match some condition imposed on a(n) and a(n-1):
A175498 (differences are unique),
A081145 (absolute differences are unique),
A235262 (bitwise XORs are unique),
A163252 (differ by one bit in binary),
A000027 (GCD=1),
A064413 (GCD>1),
A128280 (sum is a prime),
A034175 (sum is a square),
A175428 (sum is a cube),
A077220 (sum is a triangular number),
A073666 (product plus 1 is a prime),
A081943 (product minus 1 is a prime),
A091569 (product plus 1 is a square),
A100208 (sum of squares is a prime).
Cf. A004526.
Cf. A256918, A257120, A257475, A257478, A257122 (putative inverse).
Cf. also A281978.

Programs

  • Haskell
    import Data.List (delete); import Data.List.Ordered (member)
    a257218 n = a257218_list !! (n-1)
    a257218_list = 1 : f 1 [2..] a004526_list where
       f x zs cds = g zs where
         g (y:ys) | cd `member` cds = y : f y (delete y zs) (delete cd cds)
                  | otherwise       = g ys
                  where cd = gcd x y
    -- Reinhard Zumkeller, Apr 24 2015
  • Mathematica
    a={1}; used=Array[0&,10000]; Do[i=1; While[MemberQ[a,i] || used[[l=GCD[a[[-1]],i]]]>=2, i++]; used[[l]]++; AppendTo[a,i], {n,2,100}]; a (* Ivan Neretin, Apr 18 2015 *)

A257706 Sequence (a(n)) generated by Rule 1 (in Comments) with a(1) = 0 and d(1) = 1.

Original entry on oeis.org

0, 2, 1, 4, 8, 6, 3, 9, 5, 10, 17, 12, 20, 14, 7, 16, 26, 18, 29, 19, 31, 22, 11, 24, 38, 25, 13, 28, 44, 30, 15, 32, 50, 34, 53, 36, 56, 37, 58, 40, 62, 42, 21, 45, 23, 46, 71, 48, 74, 49, 76, 52, 80, 54, 27, 57, 86, 55, 87, 59, 90, 61, 94, 64, 98, 66, 33
Offset: 1

Views

Author

Clark Kimberling, May 12 2015

Keywords

Comments

Rule 1 follows. For k >= 1, let A(k) = {a(1),..., a(k)} and D(k) = {d(1),..., d(k)}. Begin with k = 1 and nonnegative integers a(1) and d(1).
Step 1: If there is an integer h such that 1 - a(k) < h < 0 and h is not in D(k) and a(k) + h is not in A(k), let d(k+1) be the greatest such h, let a(k+1) = a(k) + h, replace k by k + 1, and repeat Step 1; otherwise do Step 2.
Step 2: Let h be the least positive integer not in D(k) such that a(k) + h is not in A(k). Let a(k+1) = a(k) + h and d(k+1) = h. Replace k by k+1 and do Step 1.
Conjecture: if a(1) is an nonnegative integer and d(1) is an integer, then (a(n)) is a permutation of the nonnegative integers (if a(1) = 0) or a permutation of the positive integers (if a(1) > 0). Moreover, (d(n)) is a permutation of the integers if d(1) = 0, or of the nonzero integers if d(1) > 0.
See A257705 for a guide to related sequences.

Examples

			a(1) = 0, d(1) = 1;
a(2) = 2, d(2) = 2;
a(3) = 1, d(3) = -1;
a(4) = 4, d(4) = 3;
(The sequence d differs from A131389 only in the first 13 terms.)
		

Crossrefs

Programs

  • Mathematica
    a[1] = 0; d[1] = 1; k = 1; z = 10000; zz = 120;
    A[k_] := Table[a[i], {i, 1, k}]; diff[k_] := Table[d[i], {i, 1, k}];
    c[k_] := Complement[Range[-z, z], diff[k]];
    T[k_] := -a[k] + Complement[Range[z], A[k]];
    s[k_] := Intersection[Range[-a[k], -1], c[k], T[k]];
    Table[If[Length[s[k]] == 0, {h = Min[Intersection[c[k], T[k]]], a[k + 1] = a[k] + h, d[k + 1] = h, k = k + 1}, {h = Max[s[k]], a[k + 1] = a[k] + h, d[k + 1] = h, k = k + 1}], {i, 1, zz}];
    u = Table[a[k], {k, 1, zz}]  (* A257706 *)
    Table[d[k], {k, 1, zz}]  (* A131389 shifted *)

Formula

a(n+1) - a(n) = d(n+1) = A131389(n+1) for n >= 1.
Previous Showing 11-20 of 51 results. Next