OFFSET
1,2
COMMENTS
This sequence is a permutation of the positive integers.
a(n+1)-a(n) = A175499(n).
Conjecture: the lexicographically earliest permutation of {1,2,...n} for which differences of adjacent numbers are all distinct (cf. A131529) has, for n-->infinity, this sequence as its prefix. - Joerg Arndt, May 27 2012
LINKS
Joerg Arndt and Reinhard Zumkeller, Table of n, a(n) for n = 1..10000, first 1122 terms from Joerg Arndt
MATHEMATICA
a[1] = 1; d[1] = 0; k = 1; z = 10000; zz = 120;
A[k_] := Table[a[i], {i, 1, k}]; diff[k_] := Table[d[i], {i, 1, k}];
c[k_] := Complement[Range[-z, z], diff[k]];
T[k_] := -a[k] + Complement[Range[z], A[k]];
Table[{h = Min[Intersection[c[k], T[k]]], a[k + 1] = a[k] + h, d[k + 1] = h, k = k + 1}, {i, 1, zz}];
u = Table[a[k], {k, 1, zz}] (* Clark Kimberling, May 13 2015 *)
PROG
(Python)
A175498_list, l, s, b1, b2 = [1, 2], 2, 3, set(), set([1])
for n in range(3, 10**5):
i = s
while True:
if not (i in b1 or i-l in b2):
A175498_list.append(i)
b1.add(i)
b2.add(i-l)
l = i
while s in b1:
b1.remove(s)
s += 1
break
i += 1 # Chai Wah Wu, Dec 15 2014
(Haskell)
import Data.List (delete)
a175498 n = a175498_list !! (n-1)
a175498_list = 1 : f 1 [2..] [] where
f x zs ds = g zs where
g (y:ys) | diff `elem` ds = g ys
| otherwise = y : f y (delete y zs) (diff:ds)
where diff = y - x
-- Reinhard Zumkeller, Apr 25 2015
CROSSREFS
KEYWORD
nonn,nice
AUTHOR
Leroy Quet, May 31 2010
EXTENSIONS
More terms from Sean A. Irvine, Jan 27 2011
STATUS
approved