login
a(1)=1. a(n) = number of positive divisors of n which are not among the first (n-1) terms of the sequence.
1

%I #16 Oct 21 2017 15:40:09

%S 1,1,1,2,1,2,1,2,2,2,1,4,1,2,3,2,1,3,1,3,2,2,1,4,2,2,2,3,1,5,1,3,2,2,

%T 2,5,1,2,2,4,1,5,1,3,3,2,1,6,2,3,2,3,1,4,2,5,2,2,1,6,1,2,4,4,2,4,1,3,

%U 2,5,1,7,1,2,3,3,2,4,1,6,3,2,1,6,2,2,2,5,1,7,2,3,2,2,2,7,1,3,4,5,1,4,1,5,4

%N a(1)=1. a(n) = number of positive divisors of n which are not among the first (n-1) terms of the sequence.

%C There are only 40 distinct values among the first 10000 terms. The records occur at positions: 1, 4, 12, 30, 48, 72, 120, 180, 240, 360, 480, 720, 840, 1260, 1680, 2160, 2520, 4620, 5040, ... - _Antti Karttunen_, Oct 21 2017

%H Antti Karttunen, <a href="/A115751/b115751.txt">Table of n, a(n) for n = 1..10001</a>

%e The divisors of 12 are 1, 2, 3, 4, 6 and 12. Of these, only the four divisors 3, 4, 6 and 12 do not occur among the first 11 terms of the sequence. So a(12) = 4.

%p with(numtheory): a[1]:=1: for n from 2 to 120 do div:=divisors(n): M:=convert([seq(a[j],j=1..n-1)],set): a[n]:=nops(div minus M): od: seq(a[n],n=1..120); # _Emeric Deutsch_, Apr 01 2006

%o (Scheme)

%o ;; We define a mutual recurrence with the memoization-macro definec:

%o (definec (A115751 n) (if (= 1 n) n (length (remove (lambda (d) (zero? (modulo (Aauxseq_forA115751 (- n 1)) (A000040 d)))) (divisors n)))))

%o ;; The other member of the mutual recurrence has not been submitted. Its n-th term keeps track in its prime factorization what distinct values has so far occurred in A115751(1) .. A115751(n). That is, iff value k has occurred in range a(1) .. a(n), then the n-th term of this auxiliary sequence is divisible by the k-th prime:

%o (definec (Aauxseq_forA115751 n) (if (= 1 n) 2 (lcm (A000040 (A115751 n)) (Aauxseq_forA115751 (- n 1)))))

%o (define (divisors n) (cons 1 (proper-divisors n)))

%o (define (proper-divisors n) (let loop ((k n) (divs (list))) (cond ((= 1 k) divs) ((zero? (modulo n k)) (loop (- k 1) (cons k divs))) (else (loop (- k 1) divs)))))

%o ;; _Antti Karttunen_, Oct 21 2017

%Y Cf. A088167.

%K nonn

%O 1,4

%A _Leroy Quet_, Mar 28 2006

%E More terms from _Emeric Deutsch_, Apr 01 2006