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-10 of 21 results. Next

A175499 a(n) = A175498(n+1)-A175498(n).

Original entry on oeis.org

1, 2, -1, 3, 4, -5, 6, -4, 5, -3, 7, -8, 9, -2, 8, -10, 11, -6, 10, -14, 12, -7, 13, -12, 14, -13, 15, -11, 16, -19, 17, -9, 18, -21, 19, -17, 20, -18, 21, -15, 22, -26, 23, -16, 24, -29, 25, -22, 27, -23, 26, -25, 28, -27, 29, -28, 30, -24, 31, -35, 32, 33, -62, 34, -31, 35, -34, 36, -33, 37, -39, 38, -32, 39, -42, 40, -36
Offset: 1

Views

Author

Leroy Quet, May 31 2010

Keywords

Comments

No integer occurs in this sequence more than once, by definition. Is this sequence a permutation of the nonzero integers?

Crossrefs

Programs

  • Haskell
    a175499 n = a175499_list !! (n-1)
    a175499_list = zipWith (-) (tail a175498_list) a175498_list
    -- Reinhard Zumkeller, Apr 25 2015
  • 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]]
    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}]  (* A257884 *)
    Table[d[k], {k, 1, zz}] (* A175499 *)
    (* Clark Kimberling, May 13 2015 *)
  • Python
    A175499_list, l, s, b = [1], 2, 3, set()
    for n in range(2, 10**2):
        i, j = s, s-l
        while True:
            if not (i in b or j in A175499_list):
                A175499_list.append(j)
                b.add(i)
                l = i
                while s in b:
                    b.remove(s)
                    s += 1
                break
            i += 1
            j += 1 # Chai Wah Wu, Dec 15 2014
    

Extensions

More terms from Sean A. Irvine, Jan 27 2011

A257465 Inverse permutation to A175498.

Original entry on oeis.org

1, 2, 4, 3, 7, 5, 9, 13, 11, 6, 8, 10, 17, 21, 15, 12, 14, 19, 23, 25, 27, 31, 16, 18, 29, 22, 35, 20, 37, 33, 39, 24, 43, 26, 47, 28, 41, 49, 32, 45, 30, 51, 53, 55, 57, 36, 61, 34, 38, 64, 59, 40, 66, 68, 72, 44, 70, 76, 42, 48, 74, 78, 80, 46, 50, 84, 82
Offset: 1

Views

Author

Reinhard Zumkeller, Apr 25 2015

Keywords

Crossrefs

Cf. A175498.

Programs

  • Haskell
    import Data.List (elemIndex); import Data.Maybe (fromJust)
    a257465 = (+ 1) . fromJust . (`elemIndex` a175498_list)

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.

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

Original entry on oeis.org

1, 2, 4, 3, 6, 10, 8, 5, 11, 7, 12, 19, 14, 22, 16, 9, 18, 28, 20, 31, 21, 33, 24, 13, 26, 40, 27, 15, 30, 46, 32, 17, 34, 52, 36, 55, 38, 58, 39, 60, 42, 64, 44, 23, 47, 25, 48, 73, 50, 76, 51, 78, 54, 82, 56, 29, 59, 88, 57, 89, 61, 92, 63, 96, 66, 100, 68, 35, 70, 106, 72, 37
Offset: 1

Views

Author

Clark Kimberling, Jul 05 2007

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(2)=1+1, a(3)=a(2)+2, a(4)=a(3)+(-1), a(5)=a(4)+3, a(6)=a(5)+4.
		

Crossrefs

Programs

  • Mathematica
    (*Program 1 *)
    {a, f} = {{1}, {0}}; Do[tmp = {#, # - Last[a]} &[Max[Complement[#, Intersection[a, #]] &[Last[a] + Complement[#, Intersection[f, #]] &[Range[2 - Last[a], -1]]]]];
    If[! IntegerQ[tmp[[1]]], tmp = {Last[a] + #, #} &[NestWhile[# + 1 &, 1, ! (! MemberQ[f,#] && ! MemberQ[a, Last[a] + #]) &]]];
    AppendTo[a, tmp[[1]]]; AppendTo[f, tmp[[2]]], {400}];
    {a, f} (*{A131388, A131389}; Peter J. C. Moses, May 10 2015*)
    (*Program 2 *)
    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]];
    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}] (* A131388 *)
    Table[d[k], {k, 1, zz}]     (* A131389 *)

Formula

a(k+1) - a(k) = d(k+1) for k >= 1.

Extensions

Revised by Clark Kimberling, May 12 2015

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

Original entry on oeis.org

0, 1, 3, 2, 5, 11, 4, 9, 6, 13, 7, 15, 10, 8, 17, 35, 12, 25, 14, 29, 16, 33, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 30, 26, 53, 24, 49, 40, 28, 57, 27, 55, 31, 63, 32, 65, 38, 42, 34, 69, 36, 73, 48, 97, 44, 89, 46, 93, 51, 103, 52, 105, 50, 101
Offset: 1

Views

Author

Clark Kimberling, May 16 2015

Keywords

Comments

Rule 3 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 least 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: suppose that a(1) is an nonnegative integer and d(1) is an integer.
If a(1) = 0 and d(1) != 1, then (a(n)) is a permutation of the nonnegative integers;
if a(1) = 0 and d(1) = 1, then (a(n)) is a permutation of the nonnegative integers excluding 1;
if a(1) = 1, then (a(n)) is a permutation of the positive integers;
if a(1) > 1, then (a(n)) is a permutation of the integers >1;
if d(1) = 0, then (d(n)) is a permutation of the integers;
if d(1) !=0, then (d(n)) is a permutation of the nonzero integers.
Guide to related sequences:
a(1) d(1) (a(n)) (d(n))

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

Cf. A256283 (putative inverse).

Programs

  • Haskell
    import Data.List ((\\))
    a257905 n = a257905_list !! (n-1)
    a257905_list = 0 : f [0] [0] where
       f xs@(x:_) ds = g [2 - x .. -1] where
         g [] = y : f (y:xs) (h:ds) where
                      y = x + h
                      (h:_) = [z | z <- [1..] \\ ds, x - z `notElem` xs]
         g (h:hs) | h `notElem` ds && y `notElem` xs = y : f (y:xs) (h:ds)
                  | otherwise = g hs
                  where y = x + h
    -- Reinhard Zumkeller, Jun 03 2015
  • Mathematica
    {a, f} = {{0}, {0}}; Do[tmp = {#, # - Last[a]} &[Min[Complement[#, Intersection[a, #]]&[Last[a] + Complement[#, Intersection[f, #]] &[Range[2 - Last[a], -1]]]]];
    If[! IntegerQ[tmp[[1]]], tmp = {Last[a] + #, #} &[NestWhile[# + 1 &, 1, ! (! MemberQ[f, #] && ! MemberQ[a, Last[a] - #]) &]]]; AppendTo[a, tmp[[1]]]; AppendTo[f, tmp[[2]]], {120}]; {a, f} (* Peter J. C. Moses, May 14 2015 *)

Formula

a(n) = A258046(n) - 1 for n >= 1.

A327743 a(n) = smallest positive number not already in the sequence such that for each k = 1, ..., n-1, the k-th differences are distinct.

Original entry on oeis.org

1, 2, 4, 3, 6, 11, 5, 9, 7, 13, 10, 18, 8, 15, 27, 14, 23, 12, 22, 17, 28, 16, 29, 20, 34, 19, 35, 21, 36, 32, 24, 42, 26, 43, 25, 44, 66, 33, 53, 30, 51, 31, 54, 37, 61, 39, 64, 38, 67, 40, 70, 41, 68, 47, 75, 50, 76, 45, 77, 49, 80, 48, 81, 46, 82, 52, 86
Offset: 1

Views

Author

Peter Kagey, Sep 24 2019

Keywords

Comments

Is this sequence a permutation of the positive integers?
Does each k-th difference contain all nonzero integers?
It is not difficult to show that if a(1), ..., a(k) satisfy the requirements, then any sufficiently large number is a candidate for a(k+1). So a(k) exists for all k. - N. J. A. Sloane, Sep 24 2019
The original definition was "Lexicographically earliest infinite sequence of distinct positive integers such that for every k >= 1, the k-th differences are distinct."
If only first differences are considered, one gets the classical Mian-Chowla sequence A005282. - M. F. Hasler, Oct 09 2019

Examples

			Illustration of the first eight terms of the sequence.
k | k-th differences
--+---------------------------------
0 |   1,  2,   4,   3,   6, 11, 5, 9
1 |   1,  2,  -1,   3,   5, -6, 4
2 |   1, -3,   4,   2, -11, 10
3 |  -4,  7,  -2, -13,  21
4 |  11, -9, -11,  34
5 | -20, -2,  45
6 |  18, 47
7 |  29
		

Crossrefs

Cf. A175498.
First differences: A327452; leading column of difference triangle: A327457.
If ALL terms of the difference triangle must be distinct, see A327460 and A327762.
Cf. A005282.

Programs

  • Mathematica
    a[1] = 1;
    a[n_] := a[n] = For[aa = Array[a, n-1]; an = 1, True, an++, If[FreeQ[aa, an], aa = Append[aa, an]; If[AllTrue[Range[n-1], Unequal @@ Differences[ aa, #]&], Return[an]]]];
    a /@ Range[1, 100] (* Jean-François Alcover, Oct 26 2019 *)

Extensions

"Infinite" added to definition (for otherwise the one-term sequence 1 is earlier). - N. J. A. Sloane, Sep 25 2019
Changed definition to avoid use of "Lexicographically earliest infinite sequence" and the associated existence questions. - N. J. A. Sloane, Sep 28 2019

A231334 Lexicographically earliest sequence of distinct positive integers such that for any distinct i,j, k, the points at positions (i, a(i)), (j, a(j)), (k, a(k)) are not aligned.

Original entry on oeis.org

1, 2, 4, 3, 6, 5, 9, 12, 7, 14, 13, 8, 23, 17, 18, 22, 10, 15, 11, 28, 19, 16, 20, 29, 32, 44, 35, 39, 24, 40, 26, 37, 42, 21, 56, 64, 43, 31, 25, 34, 27, 33, 66, 67, 52, 60, 30, 57, 36, 63, 86, 82, 38, 50, 47, 69, 75, 79, 89, 49, 45, 76, 41, 48, 98, 77, 94
Offset: 1

Views

Author

Paul Tek, Nov 07 2013

Keywords

Comments

Is this a permutation of the natural numbers?
There are only two fixed points: 1 and 2.

Crossrefs

Programs

  • C
    See Link section.
  • Mathematica
    WIDTH = 1000;
    HEIGHT = 2000;
    Clear[seen, aligned, a];
    compute[n_] := Module[{c = 1}, While[seen[c] || aligned[n][c], c++; If[c > HEIGHT, Abort[]]]; a[n] = c; seen[a[n]] = True; For[i = 1, i < n, i++, dn = n - i; da = a[n] - a[i]; g = GCD[dn, da]; dn /= g; da /= g; nn = n; na = c; While[True, nn += dn; If[nn > WIDTH, Break[]]; na += da; If[na < 1 || na > HEIGHT, Break[]]; aligned[nn][na] = True]]; a[n]];
    Array[compute, WIDTH] (* Jean-François Alcover, Apr 19 2020, translated from Paul Tek's program. *)

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.
Showing 1-10 of 21 results. Next