OFFSET
1,2
COMMENTS
Sequence is a permutation of the positive integers.
LINKS
EXAMPLE
The largest proper divisor of 8 is 4. So a(8) is the 4th integer from among those not occurring among the first 7 integers of the sequence (a(8) is the 4th integer from among 7,9,10,11,13,14,..). So a(8) = 11.
MATHEMATICA
f[l_List] := Block[{k = 0, c = Divisors[Length[l] + 1][[ -2]]}, While[c > 0, k++; While[MemberQ[l, k], k++ ]; c--; ]; Append[l, k]]; Nest[f, {1}, 71] (* Ray Chandler, Jan 04 2007 *)
PROG
(Scheme, with defineperm1-macro from Antti Karttunen's IntSeq-library)
(defineperm1 (A126917 n) (if (<= n 1) n (let loop ((i (A243069 (- n 1))) (the-n-th-one (- (A032742 n) 1))) (cond ((not-lte? (A126918 i) n) (if (zero? the-n-th-one) i (loop (+ i 1) (- the-n-th-one 1)))) (else (loop (+ i 1) the-n-th-one))))))
;; We consider a > b (i.e. not less than b) also in case a is nil.
;; (Because of the stateful caching system used by defineperm1-macro):
(define (not-lte? a b) (cond ((not (number? a)) #t) (else (> a b))))
;; Antti Karttunen, Jun 20 2014
CROSSREFS
KEYWORD
nonn
AUTHOR
Leroy Quet, Dec 31 2006
EXTENSIONS
Extended by Ray Chandler, Jan 04 2007
STATUS
approved