OFFSET
1,2
COMMENTS
This sequence was called the Annoyance sequence on a Seqfan thread.
LINKS
Neal Gersh Tolunsky, Table of n, a(n) for n = 1..10000
EXAMPLE
We start with the positive integers:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...
Set a(1) = 1. The number immediately to its right, 2, is annoyed, and moves 2 steps away, so the numbers are now in the order
1, 3, 4, 2, 5, 6, 7, 8, 9, 10, ...
Then a(2) = 3, which annoys three numbers: 4 moves 4 steps, giving
1, 3, 2, 5, 6, 7, 4, 8, 9, 10, ...
after which 2 moves 2 steps, giving
1, 3, 5, 6, 2, 7, 4, 8, 9, 10, ...
and 5 moves 5 steps, giving
1, 3, 6, 2, 7, 4, 8, 5, 9, 10, ....
Now a(3) = 6, which annoys six numbers, and so on.
PROG
(Python)
N = 70
theList = [1, 2, 3, 4]
for i in range(N):
# print('Before step %d, the list is: %r' % (i+1, theList))
annoyingNumber = theList[i]
for d in range(0, annoyingNumber):
annoyedNumber = theList[i+1]
if (i+2+annoyedNumber >= len(theList)):
theList += [j for j in range(len(theList)+1, i+3+annoyedNumber)]
theList = theList[:i+1] + theList[i+2:i+2+annoyedNumber] + [annoyedNumber] + theList[i+2+annoyedNumber:]
# print(' After %d annoys %d, the list is: %r' % (annoyingNumber, annoyedNumber, theList))
print('%r' % theList[:N]) # Arthur O'Dwyer, Jul 24 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Ali Sada, Jul 20 2023
STATUS
approved