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

A364054 a(1) = 1; for n > 1, a(n) is the least positive integer not already in the sequence such that a(n) == a(n-1) (mod prime(n-1)).

Original entry on oeis.org

1, 3, 6, 11, 4, 15, 2, 19, 38, 61, 32, 63, 26, 67, 24, 71, 18, 77, 16, 83, 12, 85, 164, 81, 170, 73, 174, 277, 384, 57, 283, 29, 160, 23, 162, 13, 315, 158, 321, 154, 327, 148, 329, 138, 331, 134, 333, 122, 345, 118, 347, 114, 353, 112, 363, 106, 369, 100, 371, 94, 375, 92, 385
Offset: 1

Views

Author

Ali Sada, Oct 19 2023

Keywords

Comments

5 is the smallest positive integer missing from the first 1000 terms. Also in the interval a(100) to a(1000) there are no entries less than 100. (From W. Edwin Clark via SeqFan.)
Comments from N. J. A. Sloane, Oct 22 2023 (Start)
It appears that the graph of this sequence is dominated by pairs of diverging lines, as suggested by the sketch (see link). For example, around step n = 4619, a descending line is changing to a descending line around a(4619) = 65, a companion ascending line is coming to an end near a(4594) = 44518, and a strong ascending line is starting up around a(4620) = 88899.
It would be nice to have more terms, in order to get better estimates of the times t_i where these transitions happen, and heights alpha_i, beta_i, gamma_i where line breaks are.
The only well-defined points are the (t_i, alpha_i) where the descending lines end, as can be seen from the b-file, where the end point a(4619) = 65 is well-defined. The other transitions, where an ascending line changes to a descending line, are less obvious. It would be nice to know more.
Can the t_i and alpha_i sequences be traced back to the start of the sequence? Of course the alpha_i sequence is not monotonic, and in particular we do not know at present if some alpha_i is equal to 5.
(End)
a(28149) = 7. - Chai Wah Wu, Oct 22 2023
Comment from N. J. A. Sloane, Mar 05 2024 (Start):
At present there is no OEIS entry for the inverse sequence, since it is not known if 5 appears here.
The initial values of the inverse sequence are
n.....1..2..3..4..5..6....7.....8..9..10..11... . . .
index.1..7..2..5..?..3..28149..81..?...?...4... . . . (End)

Examples

			For n = 2, prime(2-1) = prime(1) = 2; a(1) = 1, so a(1) mod 2 = 1, so a(2) is the least positive integer == 1 (mod 2) that has not yet appeared; 1 has appeared, so a(2) = 3.
For n = 3, prime(3-1) = 3; a(2) mod 3 = 0, so a(3) is the least unused integer == 0 mod 3, which is 6, so a(3) =  6.
For n = 4, prime(4-1) = 5; a(3) mod 5 = 1, and 6 has already been used, so a(4) = 11.
		

Crossrefs

For a(n-1) (mod prime(n-1)) see A366470.
Records: A368384, A368385.
See also A366475, A366477.

Programs

  • Mathematica
    a[1] = 1; a[n_] := a[n] = Module[{p = Prime[n - 1], k = 2, s = Array[a, n - 1]}, While[! FreeQ[s, k] || ! Divisible[k - a[n - 1], p], k++]; k]; Array[a, 100] (* Amiram Eldar, Oct 20 2023 *)
    nn = 2^20; c[] := False; m[] := 0; a[1] = j = 1; c[0] = c[1] = True;
      Monitor[Do[p = Prime[n - 1]; r = Mod[j, p];
        While[Set[k, p m[p] + r ]; c[k], m[p]++];
        Set[{a[n], c[k], j}, {k, True, k}], {n, 2, nn}], n];
    Array[a, nn] (* Michael De Vlieger, Oct 26 2023, fast, based on congruence, avoids search *)
  • Python
    from itertools import count, islice
    from sympy import nextprime
    def A364054_gen(): # generator of terms
        a, aset, p = 1, {0,1}, 2
        while True:
            yield a
            for b in count(a%p,p):
                if b not in aset:
                    aset.add(b)
                    a, p = b, nextprime(p)
                    break
    A364054_list = list(islice(A364054_gen(),30)) # Chai Wah Wu, Oct 22 2023

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

Original entry on oeis.org

1, 3, 6, 11, 4, 15, 2, 19, 38, 9, 32, 63, 26, 67, 24, 71, 18, 77, 16, 83, 12, 85, 164, 81, 170, 73, 174, 65, 168, 61, 188, 75, 206, 69, 208, 59, 210, 53, 216, 49, 222, 43, 224, 33, 226, 29, 228, 17, 240, 13, 242, 475, 236, 477, 220, 471, 202, 465, 194, 487, 204, 481, 200
Offset: 1

Views

Author

Amarnath Murthy, May 24 2004

Keywords

Comments

A variation of Cald's sequence A006509; a sequence of distinct positive integers with property that absolute successive differences are distinct primes.
A more long-winded definition: Start with a(1) = 1. Keep a list of the primes that have been used so far; initially this list is empty. Each prime can be used at most once.
To get a(n), subtract from a(n-1) each prime p < a(n-1) that has not yet been used, starting from the smallest. If for any such p, a(n-1)-p is not yet in the sequence, set a(n) = a(n-1)-p and mark p as used.
If no p works, then add each prime p that has not yet been used to a(n-1), again starting with the smallest. When p is such that a(n-1)+p is not yet in the sequence, set a(n) = a(n-1)+p and mark p as used. Repeat.
The main question is: does every number appear in the sequence?

Examples

			1 -> 1+2 = 3 and prime 2 has been used.
3 -> 3+3 = 6 and prime 3 has been used.
6 could go to 6-5 = 1, except 1 is already in the sequence; so 6 -> 6+5 = 11 and prime 5 has been used.
11 -> 11-7 = 4 (for the first time we can subtract) and prime 7 has been used.
		

Crossrefs

Similar to Cald's sequence A006509 and Recamán's sequence A005132. Differs from A006509. Cf. A094746 (the primes associated with this sequence), A113959 (where n appears), A113960, A113961, A113962.
Cf. A000040.

Programs

  • Haskell
    import Data.List (delete)
    a093903 n = a093903_list !! (n-1)
    a093903_list = 1 : f [1] a000040_list where
       f xs@(x:_) ps = g ps where
         g (q:qs) | x <= q         = h ps
                  | y `notElem` xs = y : f (y:xs) (delete q ps)
                  | otherwise      = g qs where
           y = x - q
           h (r:rs) | z `notElem` xs = z : f (z:xs) (delete r ps)
                    | otherwise      = h rs where
             z = x + r
    -- Reinhard Zumkeller, Oct 17 2011

Extensions

Definition (and sequence) corrected by R. Piyo (nagoya314(AT)yahoo.com) and N. J. A. Sloane, Dec 09 2004
Edited, offset changed to 1, a(16) and following terms added by Klaus Brockhaus, Nov 10 2005

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

A110080 a(1) = 1; skipping over integers occurring earlier in the sequence, count down p(n) (p(n) = n-th prime) from a(n) to get a(n+1). If this is <= 0, instead count up from a(n) p(n) positions (skipping already occurring integers) to get a(n+1).

Original entry on oeis.org

1, 3, 6, 11, 2, 16, 29, 10, 32, 4, 39, 70, 31, 75, 27, 80, 20, 87, 17, 94, 9, 97, 176, 91, 183, 81, 188, 77, 193, 73, 198, 57, 203, 50, 206, 38, 209, 28, 216, 22, 223, 12, 226, 417, 222, 422, 219, 435, 202, 440, 199, 445, 190, 448, 177, 455, 169, 462, 166, 469, 161, 472
Offset: 1

Views

Author

Leroy Quet, Oct 12 2005

Keywords

Comments

If we did not skip earlier occurring integers when counting, we would instead have Cald's sequence (A006509).

Examples

			The first 5 terms of the sequence can be plotted on the number line as:
1,2,3,*,*,6,*,*,*,*,11,*,*,*,*,*.
a(5) is 2. Counting p(5) = 11 down from 2 gets a negative integer. So we instead count up 11 positions, skipping the 3, 6 and 11 as we count, to arrive at 16 (which is at the rightmost * of the number line above).
Here is the calculation of the first 6 terms in more detail:
integers i : 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...
i at n = ... : 1 5 2 . . 3 . . . .. .4 .. .. .. .. .6 ...
prime p used : - 7 2 . . 3 . . . .. .5 .. .. .. .. 11 ...
		

Crossrefs

Cf. A091023, A091263, A006509, A111187 (inverse).

Programs

  • Haskell
    import Data.Set (singleton, member, insert)
    a110080 n = a110080_list !! (n-1)
    a110080_list = 1 : f 1 a000040_list (singleton 1) where
       f x (p:ps) m = y : f y ps (insert y m) where
         y = g x p
         g 0 _ = h x p
         g u 0 = u
         g u v = g (u - 1) (if member (u - 1) m then v else v - 1)
         h u 0 = u
         h u v = h (u + 1) (if member (u + 1) m then v else v - 1)
    -- Reinhard Zumkeller, Sep 02 2014

Extensions

More terms from Klaus Brockhaus and Hans Havermann, Oct 17 2005

A117128 Recamán transform of primes (another version): a(0)=1; for n>0, a(n) = a(n-1) - prime(n) if that number is positive and not already in the sequence, otherwise a(n) = a(n-1) + prime(n).

Original entry on oeis.org

1, 3, 6, 11, 4, 15, 2, 19, 38, 61, 32, 63, 26, 67, 24, 71, 18, 77, 16, 83, 12, 85, 164, 81, 170, 73, 174, 277, 384, 275, 162, 35, 166, 29, 168, 317, 468, 311, 148, 315, 142, 321, 140, 331, 138, 335, 136, 347, 124, 351, 122, 355, 116, 357, 106, 363, 100, 369, 98, 375, 94, 377
Offset: 0

Views

Author

N. J. A. Sloane, Apr 20 2006

Keywords

Comments

Differs from Cald's sequence A006509 for first time at n=116 (or 117, depending on offset).

Crossrefs

Programs

  • Haskell
    import Data.Set (singleton, notMember, insert)
    a117128 n = a117128_list !! n
    a117128_list = 1 : f 1 a000040_list (singleton 1) 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
    
  • Maple
    M1:=500000; a:=array(0..M1); have:=array(1..M1); a[0]:=1; for n from 1 to M1 do have[n]:=0; od: have[1]:=1;
    M2:=2000; nmax:=M2;
    for n from 1 to M2 do p:=ithprime(n); i:=a[n-1]-p; j:=a[n-1]+p;
    if i >= 1 and have[i]=0 then a[n]:=i; have[i]:=1;
    elif j <= M1 then a[n]:=j; have[j]:=1;
    else nmax:=n-1; break; fi; od: [seq(a[n],n=0..M2)];
  • Mathematica
    a = {1}; Do[If[And[#1 > 0, ! MemberQ[a, #1]], AppendTo[a, #1], AppendTo[a, #2]] & @@ {#1 - #2, #1 + #2} & @@ {a[[n - 1]], Prime[n - 1]}, {n, 2, 62}]; a (* Michael De Vlieger, Dec 05 2016 *)
  • Python
    from sympy import primerange, prime
    def aupton(terms):
      alst = [1]
      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(61)) # Michael S. Branicky, May 30 2021

Formula

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

A368382 a(1) = 1; for n > 1, a(n) is the least positive integer not already in the sequence such that a(n) == a(n-1) (mod A004280(n)).

Original entry on oeis.org

1, 3, 6, 11, 4, 13, 2, 15, 30, 47, 9, 51, 5, 55, 28, 57, 26, 59, 24, 61, 22, 63, 20, 65, 18, 67, 16, 69, 14, 71, 12, 73, 10, 75, 8, 77, 148, 221, 146, 223, 144, 225, 142, 227, 53, 231, 49, 235, 45, 239, 41, 243, 37, 247, 33, 251, 29, 255, 25, 259, 21, 263, 17, 267, 140, 269, 7, 273, 138, 275, 136, 277, 134, 279, 132, 281
Offset: 1

Views

Author

N. J. A. Sloane, Mar 03 2024

Keywords

Comments

Analogous to A364054, but whereas that sequence is based on the sequence of primes (2, 3, 5, 7, 11, ....), the present sequence is based on the sequence 2, 3, 5, 7, 9, 11, 13, 15, ... (2 together with the odd numbers >1, essentially A004280).

Crossrefs

Cf. A004280.
Similar definitions: A005132, A006509, A364054.

Programs

  • Python
    from itertools import count, islice
    def A368382_gen(): # generator of terms
        a, aset, p = 1, {0,1}, 2
        while True:
            yield a
            for b in count(a%p,p):
                if b not in aset:
                    aset.add(b)
                    a, p = b, 3 if p == 2 else p+2
                    break
    A368382_list = list(islice(A368382_gen(),40)) # Chai Wah Wu, Mar 05 2024

A094746 Primes arising as successive differences in A093903.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 19, 29, 23, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 109, 103, 107, 127, 113, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 257, 251, 269, 263, 271, 293
Offset: 1

Views

Author

Amarnath Murthy, May 24 2004

Keywords

Comments

Differs from A006509.

Crossrefs

Formula

Absolute(A093903(n+1)-A093903(n))

Extensions

Corrected by R. Piyo (nagoya314(AT)yahoo.com) and N. J. A. Sloane, Dec 09 2004
a(15) and following terms from Klaus Brockhaus, Nov 10 2005

A112878 A100298(n) = 0.

Original entry on oeis.org

14, 34, 35, 41, 42, 56, 92, 100, 124, 132, 133, 134, 135, 153, 167, 204, 216, 217, 218, 236, 261, 269, 283, 295, 330, 342, 369, 373, 392, 443, 464, 480, 488, 521, 587, 599, 634, 648, 688, 714, 723, 742, 786, 814, 815, 816, 817, 818, 819, 820, 821, 829, 833
Offset: 1

Views

Author

Klaus Brockhaus, Oct 24 2005

Keywords

Comments

A100298 is similar to Cald's sequence A006509, where zeros are much less frequent (cf. A112877).

Examples

			A100298(14) = 0 and A100298(k) > 0 for k < 14, so a(1) = 14.
		

Crossrefs

A367188 a(1) = 1, thereafter a(n) = a(n-1) - A007504(n-1) if positive and novel, else a(n-1) + A007504(n-1).

Original entry on oeis.org

1, 3, 8, 18, 35, 7, 48, 106, 29, 129, 258, 98, 295, 57, 338, 10, 391, 831, 330, 898, 259, 971, 180, 1054, 91, 1151, 2312, 1048, 2419, 939, 2532, 812, 2663, 675, 2802, 526, 2953, 369, 3116, 202, 3289, 23, 3470, 7108, 3277, 7305, 3078, 7516, 2855, 7743, 2626, 7976
Offset: 1

Views

Author

David James Sycamore, Nov 10 2023

Keywords

Comments

A variation on Cald's sequence A006509.

Examples

			a(1)-A007504(1) = 1-2, negative so a(2) = 1+2 = 3.
a(2)-A007504(2) = 3-5, negative so a(3) = 3+5 = 8.
a(3)-A007504(3) = 8-10, negative so a(4) = 8+10 =18.
a(4)-A007504(4) = 18-17 = 1 (positive but seen before at a(1)), so a(5) = 35.
a(5)-A007504(5) = 35-28 = 7, positive and novel so a(6) = 7.
a(10)-A007504(10) = 129-129 = 0, therefore a(11) = 2*129 = 258.
		

Crossrefs

Programs

  • Mathematica
    nn = 120; c[_] := False; a[1] = j = 1; c[1] = True; s = 2;
    Do[If[Or[# < 1, c[#]], Set[k, j + s], Set[k, #]] &[j - s];
      s += Prime[n];
      Set[{a[n], j, c[k]}, {k, k, True}], {n, 2, nn}];
    Array[a, nn] (* Michael De Vlieger, Nov 10 2023 *)

Extensions

More terms from Michael De Vlieger, Nov 10 2023
Previous Showing 11-19 of 19 results.