login
a(1) = 1; for n > 1, a(n) = 1 + greatest common divisor of n and a(n-1).
3

%I #20 Jan 10 2017 19:15:55

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

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

%U 4,3,2,3,2,3,4,5,2,3,2,3,4,3,2,3,2,3,4,5,2,3,2,3,4,3,2,3,2,3,4,5,2,3,2,3,4

%N a(1) = 1; for n > 1, a(n) = 1 + greatest common divisor of n and a(n-1).

%C a(A060401(n)) = n + 1; a(A192489(n)) = 2. - _Reinhard Zumkeller_, Jul 02 2011

%C For n >= 3, a(n) == n+1 (mod 2). - _Robert Israel_, Jan 10 2017

%H Reinhard Zumkeller, <a href="/A099427/b099427.txt">Table of n, a(n) for n = 1..10000</a>

%e a(9)=4 because 1+gcd(a(8),9)=1+gcd(3,9)=1+3.

%p f:= proc(n) option remember; 1 + igcd(n,procname(n-1)) end proc:

%p f(1):= 1:

%p map(f, [$1..1000]); # _Robert Israel_, Jan 10 2017

%t a[1] = 1; a[n_] := a[n] = GCD[n, a[n - 1]] + 1; Table[ a[n], {n, 105}] (* _Robert G. Wilson v_, Nov 18 2004 *)

%t nxt[{n_,a_}]:={n+1,GCD[n+1,a]+1}; Transpose[NestList[nxt,{1,1},110]] [[2]] (* _Harvey P. Dale_, Nov 22 2014 *)

%o (Haskell)

%o a099427 n = a099427_list !! (n-1)

%o a099427_list = 1 : map (+ 1) (zipWith gcd [2..] a099427_list)

%o -- _Reinhard Zumkeller_, Jun 23 2015, Jul 02 2011

%Y For position of first occurrence of n see A060401.

%K easy,nonn,nice

%O 1,2

%A Gaetan Polard (gaetan27(AT)hotmail.com), Nov 18 2004

%E Edited and extended by _Robert G. Wilson v_, Nov 18 2004