# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/ Search: id:a064434 Showing 1-1 of 1 %I A064434 #21 Sep 08 2022 08:45:04 %S A064434 0,1,0,1,3,1,3,7,6,3,7,3,7,1,3,7,15,13,8,17,14,7,15,7,15,5,11,23,18,7, %T A064434 15,31,30,27,20,5,11,23,8,17,35,29,16,33,22,45,44,41,34,19,39,27,2,5, %U A064434 11,23,47,37,16,33,6,13,27,55,46,27,55,43,18,37,4,9,19,39,4,9,19,39,0 %N A064434 a(n) = (2*a(n-1) + 1) mod n. %C A064434 a(n) is the remainder when (2*a(n-1) + 1) is divided by n. %C A064434 Can be generalized to a(n) = f(a(n-1)) mod n, where f is any polynomial function. %H A064434 Harry J. Smith, Table of n, a(n) for n = 1..1000 %F A064434 a(n) = (a(n-1) * 2 + 1) mod n. %e A064434 0, (0*2+1) mod 2 = 1, (1*2+1) mod 3 = 0, (0*2+1) mod 4 = 1, (1*2+1) mod 5 = 3 (3*2+1) mod 6 = 1. %t A064434 nxt[{n_,a_}]:={n+1,Mod[2a+1,n+1]}; Transpose[NestList[nxt,{1,0},80]][[2]] (* _Harvey P. Dale_, Feb 10 2014 *) %o A064434 (PARI) { a=0; for (n=1, 1000, a=(2*a + 1)%n; write("b064434.txt", n, " ", a); ) } \\ _Harry J. Smith_, Sep 13 2009 %o A064434 (Magma) [n le 1 select n-1 else (2*Self(n-1)+1) mod n: n in [1..80]]; // _Vincenzo Librandi_, Jun 24 2018 %o A064434 (GAP) a:=[0];; for n in [2..90] do a[n]:=(2*a[n-1]+1) mod n; od; a; # _Muniru A Asiru_, Jun 24 2018 %Y A064434 Cf. A064456, A079878. %K A064434 nonn %O A064434 1,5 %A A064434 Jonathan Ayres (JonathanAyres(AT)btinternet.com), Oct 01 2001 # Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE