cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-2 of 2 results.

A064434 a(n) = (2*a(n-1) + 1) mod n.

Original entry on oeis.org

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, 15, 31, 30, 27, 20, 5, 11, 23, 8, 17, 35, 29, 16, 33, 22, 45, 44, 41, 34, 19, 39, 27, 2, 5, 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
Offset: 1

Views

Author

Jonathan Ayres (JonathanAyres(AT)btinternet.com), Oct 01 2001

Keywords

Comments

a(n) is the remainder when (2*a(n-1) + 1) is divided by n.
Can be generalized to a(n) = f(a(n-1)) mod n, where f is any polynomial function.

Examples

			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.
		

Crossrefs

Programs

  • 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
  • Magma
    [n le 1 select n-1 else (2*Self(n-1)+1) mod n: n in [1..80]]; // Vincenzo Librandi, Jun 24 2018
    
  • Mathematica
    nxt[{n_,a_}]:={n+1,Mod[2a+1,n+1]}; Transpose[NestList[nxt,{1,0},80]][[2]] (* Harvey P. Dale, Feb 10 2014 *)
  • PARI
    { a=0; for (n=1, 1000, a=(2*a + 1)%n; write("b064434.txt", n, " ", a); ) } \\ Harry J. Smith, Sep 13 2009
    

Formula

a(n) = (a(n-1) * 2 + 1) mod n.

A079878 a(1)=1, then a(n)=2*a(n-1) if 2*a(n-1)<=n, a(n)=2*a(n-1)-n otherwise.

Original entry on oeis.org

1, 2, 1, 2, 4, 2, 4, 8, 7, 4, 8, 4, 8, 2, 4, 8, 16, 14, 9, 18, 15, 8, 16, 8, 16, 6, 12, 24, 19, 8, 16, 32, 31, 28, 21, 6, 12, 24, 9, 18, 36, 30, 17, 34, 23, 46, 45, 42, 35, 20, 40, 28, 3, 6, 12, 24, 48, 38, 17, 34, 7, 14, 28, 56, 47, 28, 56, 44, 19, 38, 5, 10, 20, 40, 5, 10, 20, 40, 1, 2
Offset: 1

Views

Author

Benoit Cloitre, Feb 20 2003

Keywords

Comments

a(A200087(n)) = n and a(m) <> n for m < A200087(n). [Reinhard Zumkeller, Nov 13 2011]

Crossrefs

Cf. A200063 (fixed points), A064456 (positions of 1).

Programs

  • Haskell
    a079878 n = a079878_list !! (n-1)
    a079878_list = 1 : zipWith (\x n -> if x <= n then x else x - n)
                               (map (* 2) a079878_list) [2..]
    -- Reinhard Zumkeller, Nov 13 2011
  • Mathematica
    nxt[{n_,a_}]:={n+1,If[2a<=n+1,2a,2a-n-1]}; Transpose[NestList[nxt,{1,1},80]][[2]] (* Harvey P. Dale, Jul 20 2015 *)
  • PARI
    a=1; for(n=2,100,b=if(sign(2*a-n)-1,2*a,2*a-n); a=b; print1(b,","))
    

Formula

a(n) = A064434(n)+1.
It seems that sum(k=1, n, a(k))/n^2 ->1/4
Showing 1-2 of 2 results.