A091023
a(1)=1; for n >= 2, set a(n)=m, where n is the smallest unassigned index with exactly m-1 unassigned indices still remaining between m and m-1.
Original entry on oeis.org
1, 2, 13, 3, 6, 26, 4, 11, 205, 9, 5, 24, 7, 51, 22, 102, 20, 49, 18, 8, 410, 10, 16, 12, 47, 14, 100, 45, 203, 43, 98, 41, 3277, 39, 96, 37, 201, 35, 94, 15, 33, 17, 408, 19, 31, 21, 92, 23, 29, 25, 199, 27, 90, 819, 88, 197, 86, 406, 84, 195, 82, 1638, 80, 193, 78, 404
Offset: 1
After 1 has been assigned to a(1), the first unassigned term that is one term away from 1 is a(2), so a(2)=2;
the first unassigned term that is two terms away from 2 is a(4), so a(4)=3;
the first unassigned term that is 3 terms away from 3 is a(7), so a(7)=4;
the first unassigned term that is 4 terms away from 4 is a(11), so a(11)=5;
at this point we have 1,2,*,3,*,*,4,*,*,*,5,..., where * indicates a term to which a value has not yet been assigned.
The next value to assign is 6 which must be assigned to the first term of the sequence that is 5 terms away from a(11)=5; since a(5) has not yet been assigned a value and since at this point 5 terms with unassigned values lie between a(5) and a(11), we must assign 6 to a(5), i.e., a(5)=6.
-
nmax := 20000 : a := [seq(0,i=1..nmax)] : a := subsop(1=1,a) : a := subsop(2=2,a) : prevn := 2 : n := 3: while true do us := n ; atst := prevn-1 ; tstdown := false ; while us > 0 and atst>0 do if op(atst,a) =0 then us := us-1 ; if us = 1 then tstdown := true ; a := subsop(atst=n,a) ; prevn := atst ; break ; fi ; fi ; atst := atst -1 ; od ; if tstdown = false then us := n ; atst := prevn+1 ; while us > 0 do if op(atst,a) =0 then us := us-1 ; if us = 1 then a := subsop(atst=n,a) ; prevn := atst ; break ; fi ; fi ; atst := atst +1 ; od ; fi ; for i from 1 to 150 do printf("%d, ",op(i,a)) ; od ; print() ; n := n+1 ; od : # R. J. Mathar, Apr 28 2007
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
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 ...
-
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
A378821
Lexicographically earliest sequence of distinct positive integers such that the count of integers between a(n) and a(n-1), excluding values already in the sequence, is distinct from the same count for any other a(k) and a(k-1) at the time they occurred.
Original entry on oeis.org
1, 2, 4, 7, 11, 3, 10, 18, 5, 16, 26, 6, 22, 35, 8, 27, 42, 9, 32, 51, 12, 37, 58, 13, 41, 66, 14, 47, 74, 15, 53, 83, 17, 57, 90, 19, 62, 98, 20, 68, 106, 21, 73, 115, 23, 78, 122, 24, 84, 131, 25, 88, 138, 28, 94, 147, 29, 99, 154, 30, 103, 162, 31, 109, 170, 33
Offset: 1
a(1-5) = 1,2,4,7,11 follow a straightforward pattern of counting up, where each pair of consecutive terms encloses (in order) 0,1,2,3 unused values.
1,2,3,4,5,6,7,8,9,10,11
1 2 * 4 * * 7 * * * 11
^ ^ ^ ^ ^
At a(6), a(5)=11 and a(6)=3 enclose 5 unused values:
1,2,3,4,5,6,7,8,9,10,11
1 2 3 4 * * 7 * * * 11
^ ^
-
from itertools import count, islice
def c(k, m, a): return sum(1 for i in range(min(k, m)+1, max(k, m)) if i not in a)
def agen(): # generator of terms
a, d, an, m = set(), set(), 1, 2
while True:
yield an
a.add(an)
found, k = False, m
if m < an:
ck = c(k, an, a)
for k in range(m, an):
if k not in a:
if ck not in d:
found = True
break
ck -= 1
if not found:
kk = max(m, an+1)
ck = c(kk, an, a)
for k in count(kk):
if k not in a:
if ck not in d:
found = True
break
ck += 1
d.add(c(an, k, a))
an = k
while m in a: m += 1
print(list(islice(agen(), 66))) # Michael S. Branicky, Dec 09 2024
Showing 1-3 of 3 results.
Comments