login
A113963
a(1)=1; for n>1, a(n) is the smallest positive integer not occurring earlier in the sequence where |a(n)-a(n-1)| does not divide (a(n)+a(n-1)).
6
1, 4, 7, 2, 5, 8, 3, 10, 13, 6, 11, 14, 9, 16, 19, 12, 17, 20, 23, 15, 22, 25, 18, 26, 21, 29, 24, 31, 27, 32, 35, 38, 28, 33, 37, 30, 39, 34, 40, 43, 36, 41, 44, 47, 42, 50, 53, 45, 49, 46, 51, 55, 48, 57, 52, 58, 61, 54, 59, 56, 62, 65, 68, 63, 67, 60, 69, 64, 70, 73, 66, 71
OFFSET
1,2
COMMENTS
Sequence is a permutation of the positive integers.
EXAMPLE
Among those positive integers not among the first 4 integers of the sequence, a(5) = 5 is the lowest such that |a(5)-a(4)| = |5-2| = 3 does not divide (a(5)+a(4)) = 5+2 = 7. 3, for example, is not among the first 4 terms of the sequence, but |3-2| = 1 does indeed divide (3+2). So a(5) is not 3, but is instead 5.
MATHEMATICA
f[l_] := Block[{k=1, m}, m = Last[l]; While[MemberQ[l, k] || Mod[m + k, Abs[k - m]] == 0, k++ ]; Return[Append[l, k]]; ]; Nest[f, {1}, 100] (* Ray Chandler, Nov 13 2005 *)
PROG
(Haskell)
import Data.List (delete)
a113963 n = a113963_list !! (n-1)
a113963_list = 1 : f 1 [2..] where
f z xs = g xs where
g (y:ys) = if (y + z) `mod` abs (y - z) > 0
then y : f y (delete y xs) else g ys
-- Reinhard Zumkeller, Sep 04 2014
(Python)
A113963 = [1]
for n in range(1, 10**2):
....a, b = 1, A113963[-1]
....while a in A113963 or not (a+b) % (a-b):
........a += 1
....A113963.append(a) # Chai Wah Wu, Sep 05 2014
CROSSREFS
Cf. A246433 (inverse), A246704 (fixed points).
Sequence in context: A164106 A348930 A159895 * A071932 A246433 A324273
KEYWORD
nonn
AUTHOR
Leroy Quet, Nov 10 2005
EXTENSIONS
Extended by Ray Chandler, Nov 13 2005
STATUS
approved