login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(n) = 2^(a(n-1)) mod n.
4

%I #25 Jan 30 2015 19:49:31

%S 0,1,2,0,1,2,4,0,1,2,4,4,3,8,1,2,4,16,5,12,1,2,4,16,11,20,4,16,25,2,4,

%T 16,31,26,4,16,9,18,25,32,37,2,4,16,16,32,42,16,23,8,1,2,4,16,31,16,

%U 43,56,15,8,12,4,16,0,1,2,4,16,55,58,29,32,32,44,16,24,71,20,9,32,49,20,37

%N a(n) = 2^(a(n-1)) mod n.

%C All positive integers seem to occur somewhere in this sequence (a proof would be nice!).

%C The first occurrence of 6 is at a(59474).

%C The first occurrence of 33 is at a(2514233).

%C a(A192362(n)) = n and a(m) <> n for m < A192362(n). - _Reinhard Zumkeller_, Jun 30 2011

%C The first occurrence of 75 is at a(8654593). - _Reinhard Zumkeller_, Jan 30 2015

%H N. J. A. Sloane and T. D. Noe, <a href="/A131644/b131644.txt">Table of n, a(n) for n = 1..60000</a> (the first 1000 terms from T. D. Noe)

%F a(n) = 2^(a(n-1)) mod n, a(1) = 0

%e a(11) = 4, so a(12) = 2^a(11) mod 12 = 16 mod 12 = 4.

%t Transpose[NestList[{Mod[2^First[#],Last[#]+1],Last[#]+1}&,{0,1}, 95]][[1]] (* _Harvey P. Dale_, Apr 17 2011 *)

%t Join[{s=0}, Table[s = PowerMod[2, s, n], {n, 2, 100}]] (* _T. D. Noe_, Apr 17 2011 *)

%o (Haskell)

%o import Math.NumberTheory.Moduli (powerMod)

%o a131644 n = a131644_list !! (n-1)

%o a131644_list = map fst $ iterate f (0, 2) where

%o f (v, w) = (powerMod 2 v w, w + 1)

%o -- _Reinhard Zumkeller_, Jan 30 2015

%Y For records see A241582, A241583, also A192362.

%K easy,nonn,nice

%O 1,3

%A Jon Ayres (jonathan.ayres(AT)ntlworld.com), Sep 08 2007