login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A254788 Lexicographically earliest permutation of the natural numbers, such that both numbers a(n)+a(n+1) and abs(a(n)-a(n+1)) occur all in all not more than once. 4
1, 2, 4, 8, 3, 10, 18, 9, 23, 6, 16, 31, 5, 25, 41, 7, 26, 44, 13, 36, 15, 39, 14, 49, 11, 48, 87, 12, 52, 93, 17, 60, 102, 19, 63, 108, 20, 66, 116, 21, 73, 128, 22, 78, 136, 24, 85, 147, 27, 92, 159, 28, 96, 165, 29, 100, 172, 30, 103, 177, 33, 113, 34 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
COMMENTS
We want the sequence S to be a permutation of the positive integers.
We want S to be the lexicographically earliest sequence with these properties:
If we take two adjacent integers of S, say p & q, then:
- no other pair of adjacent integers in S has the same absolute difference |p-q|,
- no other pair of adjacent integers in S has the same sum (p+q),
- no |p-q|=(p'+q') with p'and q' being two other adjacent integers in S.
So S is extended with the smallest integer n such that neither |a(n-1)-a(n)|nor [a(n-1)+a(n)] has occurred before as a sum or as a difference of two adjacent integers in S.
A254792(n) = abs(a(n)-a(n+1));
A254793(n) = a(n) + a(n+1).
LINKS
Éric Angelini, Absolute diff and sums not to be shared, SeqFan list, Jan 15 2015.
EXAMPLE
The sequence begins like this, together with their pairwise sums and absolute differences:
. A254793(n): 3 6 12 11 13 28 27 32 29 22 47 36 30 66 48 33 70 ...
. a(n): 1 2 4 8 3 10 18 9 23 6 16 31 5 25 41 7 26 44 ...
. A254792(n): 1 2 4 5 7 8 9 14 17 10 15 26 20 16 34 19 18 ...
PROG
(Haskell)
import Data.List (delete)
a254788 n = a254788_list !! (n-1)
a254788_list = 1 : f [2..] 1 [] where
f xs y zs = g xs where
g (w:ws) | s `elem` zs || d `elem` zs = g ws
| otherwise = w : f (delete w xs) w (d : s : zs)
where s = y + w; d = abs (y - w)
CROSSREFS
Cf. A254790 (inverse), A254792, A254793.
Sequence in context: A319268 A277272 A109588 * A347669 A352812 A052331
KEYWORD
nonn
AUTHOR
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 08:45 EDT 2024. Contains 371782 sequences. (Running on oeis4.)