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.

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

Original entry on oeis.org

0, 0, 1, 0, 1, 2, 1, 0, 4, 2, 1, 8, 1, 2, 4, 0, 1, 14, 1, 8, 4, 2, 1, 8, 16, 2, 13, 8, 1, 2, 1, 0, 4, 2, 9, 32, 1, 2, 4, 8, 1, 32, 1, 8, 31, 2, 1, 32, 15, 12, 4, 8, 1, 14, 49, 16, 4, 2, 1, 8, 1, 2, 4, 0, 16, 32, 1, 8, 4, 22, 1, 32, 1, 2, 34, 8, 9, 32, 1, 48, 40, 2, 1, 32, 16, 2, 4, 40, 1, 32, 64, 8, 4, 2, 54, 32, 1, 58, 58, 88, 1, 32, 1, 24, 46
Offset: 1

Views

Author

Henry Bottomley, Jun 12 2001

Keywords

Comments

If p is an odd prime then a(p)=1. However, a(n) is also 1 for pseudoprimes to base 2 such as 341.

Examples

			a(5) = 2^(5-1) mod 5 = 16 mod 5 = 1.
		

Crossrefs

Cf. A176997 (after the initial term, gives the positions of ones).

Programs

  • Haskell
    import Math.NumberTheory.Moduli (powerMod)
    a062173 n = powerMod 2 (n - 1) n  -- Reinhard Zumkeller, Oct 17 2015
    
  • Magma
    [Modexp(2,n-1,n): n in [1..110]]; // G. C. Greubel, Jan 11 2023
    
  • Mathematica
    Array[Mod[2^(# - 1), #] &, 105] (* Michael De Vlieger, Jul 01 2018 *)
    Array[PowerMod[2,#-1,#]&,120] (* Harvey P. Dale, May 17 2023 *)
  • PARI
    A062173(n) = if(1==n, 0, lift(Mod(2, n)^(n-1))); \\ Antti Karttunen, Jul 01 2018
    
  • SageMath
    [power_mod(2,n-1,n) for n in range(1,110)] # G. C. Greubel, Jan 11 2023

Formula

a(n) = A106262(2*n-3, n-2). - G. C. Greubel, Jan 11 2023

Extensions

More terms from Antti Karttunen, Jul 01 2018