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
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
Éric Angelini, Absolute diff and sums not to be shared, SeqFan list, Jan 15 2015.
EXAMPLE
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
KEYWORD
nonn
AUTHOR
Eric Angelini and Reinhard Zumkeller, Feb 07 2015
STATUS
approved