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-10 of 12 results. Next

A002371 Period of decimal expansion of 1/(n-th prime) (0 by convention for the primes 2 and 5).

Original entry on oeis.org

0, 1, 0, 6, 2, 6, 16, 18, 22, 28, 15, 3, 5, 21, 46, 13, 58, 60, 33, 35, 8, 13, 41, 44, 96, 4, 34, 53, 108, 112, 42, 130, 8, 46, 148, 75, 78, 81, 166, 43, 178, 180, 95, 192, 98, 99, 30, 222, 113, 228, 232, 7, 30, 50, 256, 262, 268, 5, 69, 28, 141, 146, 153, 155, 312, 79, 110
Offset: 1

Views

Author

Keywords

Comments

a(n) is the minimum solution x of modular equation 10^x == 1 (mod p), where p = prime(n). - Carmine Suriano, Oct 10 2012
a(n) = smallest m such that 111...11 (m 1's) is divisible by the n-th prime, or 0 if no such m exists (with the exception that a(2) = 3 instead of 1). E.g., the 5th prime, 11, divides 11, so a(5) = 2. - N. J. A. Sloane, Oct 03 2013 [Comment corrected by Derek Orr, Jun 14 2014]
Numbers n such that A071126(n) = A000040(n) - 1. - Hugo Pfoertner, Mar 18 2003
Except for n = 1 and 3, a(n) divides A006093(n). - Robert Israel, Jul 15 2016

Examples

			A002371(11) = 15 because the 11th prime is 31, and 1/31 = 0.03225806451612903225806451612903225806452... has period 15. - _Richard F. Lyon_, Mar 29 2022
		

References

  • Albert H. Beiler, Recreations in the Theory of Numbers, 2nd ed. New York: Dover, 1966, pages 65, 309. ISBN 0-486-21096-0.
  • John H. Conway and R. K. Guy, The Book of Numbers, Copernicus Press, 1996, p. 162. ISBN 978-0-387-97993-9.
  • D. H. Lehmer, Guide to Tables in the Theory of Numbers. Bulletin No. 105, National Research Council, Washington, DC, 1941, p. 15.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

See A048595 for another version. Cf. A006883, A007732, A051626, A071126, A000040, A002275, A097443.
Cf. A001913 (full repetend primes), A060257 (1/prime(n) has period prime(n) - 1).

Programs

  • Maple
    seq(subs(FAIL=0,numtheory:-order(10, ithprime(n))),n=1..100); # Robert Israel, Jul 15 2016
  • Mathematica
    Table[ Length[ RealDigits[1 / Prime[n]] [[1, 1]]], {n, 1, 70}]
    Table[If[IntegerQ[#], #, 0] &[MultiplicativeOrder[10, Prime[n]]], {n, 1, 70}] (* Jan Mangaldan, Jul 07 2020 *)
  • PARI
    a(n)=if(n<4,n==2,znorder(Mod(10, prime(n))))
    
  • Python
    from sympy import prime, n_order
    def A002371(n): return 0 if n == 1 or n == 3 else n_order(10,prime(n)) # Chai Wah Wu, Feb 07 2022

Formula

From Alexander Adamchuk, Jan 28 2007: (Start)
a(A000720(p)) = p - 1 for primes p in A001913.
a(A060257(n)) = prime(A060257(n)) - 1. (End)

Extensions

More terms from Arlin Anderson (starship1(AT)gmail.com)
Edited by Charles R Greathouse IV, Mar 24 2010

A051626 Period of decimal representation of 1/n, or 0 if 1/n terminates.

Original entry on oeis.org

0, 0, 1, 0, 0, 1, 6, 0, 1, 0, 2, 1, 6, 6, 1, 0, 16, 1, 18, 0, 6, 2, 22, 1, 0, 6, 3, 6, 28, 1, 15, 0, 2, 16, 6, 1, 3, 18, 6, 0, 5, 6, 21, 2, 1, 22, 46, 1, 42, 0, 16, 6, 13, 3, 2, 6, 18, 28, 58, 1, 60, 15, 6, 0, 6, 2, 33, 16, 22, 6, 35, 1, 8, 3, 1, 18, 6, 6, 13, 0, 9, 5, 41, 6, 16, 21, 28, 2, 44, 1
Offset: 1

Views

Author

Keywords

Comments

Essentially same as A007732.
For any prime number p: if a(p) > 0, a(p) divides p-1. - David Spitzer, Jan 09 2017

Examples

			From _M. F. Hasler_, Dec 14 2015: (Start)
a(1) = a(2) = 0 because 1/1 = 1 and 1/2 = 0.5 have a finite decimal expansion.
a(3) = a(6) = a(9) = a(12) = 1 because 1/3 = 0.{3}*, 1/6 = 0.1{6}*, 1/9 = 0.{1}*, 1/12 = 0.08{3}* where the sequence of digits {...}* which repeats indefinitely is of length 1.
a(7) = 6 because 1/7 = 0.{142857}* with a period of 6.
a(17) = 16 because 1/17 = 0.{0588235294117647}* with a period of 16.
a(19) = 18 because 1/19 = 0.{052631578947368421}* with a period of 18. (End)
		

Crossrefs

Essentially same as A007732. Cf. A002371, A048595, A006883, A036275, A114205, A114206, A001913.

Programs

  • Maple
    A051626 := proc(n) local lpow,mpow ;
        if isA003592(n) then
           RETURN(0) ;
        else
           lpow:=1 ;
           while true do
              for mpow from lpow-1 to 0 by -1 do
                  if (10^lpow-10^mpow) mod n =0 then
                     RETURN(lpow-mpow) ;
                  fi ;
              od ;
              lpow := lpow+1 ;
           od ;
        fi ;
    end: # R. J. Mathar, Oct 19 2006
  • Mathematica
    r[x_]:=RealDigits[1/x]; w[x_]:=First[r[x]]; f[x_]:=First[w[x]]; l[x_]:=Last[w[x]]; z[x_]:=Last[r[x]];
    d[x_] := Which[IntegerQ[l[x]], 0, IntegerQ[f[x]]==False, Length[f[x]], True, Length[l[x]]]; Table[d[i], {i,1,90}] (* Hans Havermann, Oct 19 2006 *)
    fd[n_] := Block[{q},q = Last[First[RealDigits[1/n]]];If[IntegerQ[q], q = {}]; Length[q]];Table[fd[n], {n, 100}] (* Ray Chandler, Dec 06 2006 *)
    Table[Length[RealDigits[1/n][[1,-1]]],{n,90}] (* Harvey P. Dale, Jul 03 2011 *)
    a[n_] := If[ PowerMod[10, n, n] == 0, 0, MultiplicativeOrder[10, n/2^IntegerExponent[n, 2]/5^IntegerExponent[n, 5]]]; Array[a, 90] (* myself in A003592 and T. D. Noe in A007732 *) (* Robert G. Wilson v, Feb 20 2025 *)
  • PARI
    A051626(n)=if(1M. F. Hasler, Dec 14 2015
    
  • Python
    def A051626(n):
        if isA003592(n):
            return 0
        else:
            lpow=1
            while True:
                for mpow in range(lpow-1,-1,-1):
                    if (10**lpow-10**mpow) % n == 0:
                        return lpow-mpow
                lpow += 1 # Kenneth Myers, May 06 2016
    
  • Python
    from sympy import multiplicity, n_order
    def A051626(n): return 0 if (m:=(n>>(~n & n-1).bit_length())//5**multiplicity(5,n)) == 1 else n_order(10,m) # Chai Wah Wu, Aug 11 2022

Formula

a(n)=A132726(n,1); a(n)=a(A132740(n)); a(A132741(n))=a(A003592(n))=0. - Reinhard Zumkeller, Aug 27 2007

Extensions

More terms from James Sellers

A006556 Number of different cycles of digits in the decimal expansions of 1/p, 2/p, ..., (p-1)/p where p = n-th prime different from 2 or 5.

Original entry on oeis.org

2, 1, 5, 2, 1, 1, 1, 1, 2, 12, 8, 2, 1, 4, 1, 1, 2, 2, 9, 6, 2, 2, 1, 25, 3, 2, 1, 1, 3, 1, 17, 3, 1, 2, 2, 2, 1, 4, 1, 1, 2, 1, 2, 2, 7, 1, 2, 1, 1, 34, 8, 5, 1, 1, 1, 54, 4, 10, 2, 2, 2, 2, 1, 4, 3, 1, 2, 3, 11, 2, 1, 2, 1, 1, 1, 4, 2, 2, 1, 3, 2, 1, 2, 2, 14, 3, 1, 3, 2, 2, 1, 1, 1, 1, 1, 10, 2, 1, 6
Offset: 3

Views

Author

Keywords

Examples

			1/13=.0769230769..., 2/13=.1538461538..., 3/13= .2307692307..., etc., with 2 different cycles, so a(4) = 2 [13 is the 4th prime different from 2 or 5].
		

References

  • J. H. Conway and R. K. Guy, The Book of Numbers, Copernicus Press, NY, 1996, p. 162.
  • M. Kraitchik, Recherches sur la Théorie des Nombres. Gauthiers-Villars, Paris, Vol. 1, 1924, Vol. 2, 1929, see Vol. 1, p. 131.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

See A048595 and A002371 for the length of the cycles. See also A054471.

Programs

  • Mathematica
    Map[(# - 1)/MultiplicativeOrder[10, #] &, {3}~Join~Prime@ Range[4, 101]] (* Michael De Vlieger, May 27 2020 *)
  • PARI
    f(p) = (p-1)/znorder(Mod(10, p));
    lista(nn) = {my(vp=select(x->(10%x), primes(nn))); apply(f, vp);} \\ Michel Marcus, May 27 2020

Formula

(p-1)/x, where 10^x = 1 mod p.

Extensions

More terms from James Sellers, May 24 2000
Edited by Charles R Greathouse IV, Nov 01 2009

A036275 The periodic part of the decimal expansion of 1/n. Any initial 0's are to be placed at end of cycle.

Original entry on oeis.org

0, 0, 3, 0, 0, 6, 142857, 0, 1, 0, 90, 3, 769230, 714285, 6, 0, 5882352941176470, 5, 526315789473684210, 0, 476190, 45, 4347826086956521739130, 6, 0, 384615, 370, 571428, 3448275862068965517241379310, 3, 322580645161290, 0, 30, 2941176470588235, 285714, 7
Offset: 1

Views

Author

Keywords

Comments

a(n) = 0 iff n = 2^i*5^j (A003592). - Jon Perry, Nov 19 2014
a(n) = n iff n = 3 or 6 (see De Koninck & Mercier reference). - Bernard Schott, Dec 02 2020

Examples

			1/28 = .03571428571428571428571428571428571428571... and digit-cycle is 571428, so a(28)=571428.
		

References

  • Jean-Marie De Koninck & Armel Mercier, 1001 Problèmes en Théorie Classique des Nombres, Problème 347 pp. 50 and 205, Ellipses, Paris, 2004.

Crossrefs

Programs

  • Maple
    isCycl := proc(n) local ifa,i ; if n <= 2 then RETURN(false) ; fi ; ifa := ifactors(n)[2] ; for i from 1 to nops(ifa) do if op(1,op(i,ifa)) <> 2 and op(1,op(i,ifa)) <> 5 then RETURN(true) ; fi ; od ; RETURN(false) ; end: A036275 := proc(n) local ifa,sh,lpow,mpow,r ; if not isCycl(n) then RETURN(0) ; else lpow:=1 ; while true do for mpow from lpow-1 to 0 by -1 do if (10^lpow-10^mpow) mod n =0 then r := (10^lpow-10^mpow)/n ; r := r mod (10^(lpow-mpow)-1) ; while r*10 < 10^(lpow-mpow) do r := 10*r ; od ; RETURN(r) ; fi ; od ; lpow := lpow+1 ; od ; fi ; end: for n from 1 to 60 do printf("%d %d ",n,A036275(n)) ; od ; # R. J. Mathar, Oct 19 2006
  • Mathematica
    fc[n_]:=Block[{q=RealDigits[1/n][[1,-1]]},If[IntegerQ[q],0,While[First[q]==0,q=RotateLeft[q]];FromDigits[q]]];
    Table[fc[n],{n,36}] (* Ray Chandler, Nov 19 2014, corrected Jun 27 2017 *)
    Table[FromDigits[FindTransientRepeat[RealDigits[1/n,10,120][[1]],3] [[2]]],{n,40}] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Mar 12 2019 *)

Extensions

Corrected and extended by N. J. A. Sloane
Corrected a(92), a(208), a(248), a(328), a(352) and a(488) which missed a trailing zero (see the table). - Philippe Guglielmetti, Jun 20 2017

A040017 Prime 3 followed by unique period primes (the period r of 1/p is not shared with any other prime) of the form A019328(r)/gcd(A019328(r),r) in order (periods r are given in A051627).

Original entry on oeis.org

3, 11, 37, 101, 9091, 9901, 333667, 909091, 99990001, 999999000001, 9999999900000001, 909090909090909091, 1111111111111111111, 11111111111111111111111, 900900900900990990990991, 909090909090909090909090909091
Offset: 1

Views

Author

Keywords

Comments

Prime p=3 is the only known example of a unique period prime such that A019328(r)/gcd(A019328(r),r) = p^k with k > 1 (cf. A323748). It is plausible to assume that no other such prime exists. Under this (unproved) assumption, the current sequence lists all unique period primes in order and represents a sorted version of A007615. - Max Alekseyev, Oct 14 2022

Examples

			The decimal expansion of 1/101 is 0.00990099..., having a period of 4 and it is the only prime with that period.
		

References

  • J.-P. Delahaye, Merveilleux nombres premiers ("Amazing primes"), p. 324, Pour la Science Paris 2000.

Crossrefs

Programs

  • Mathematica
    lst = {}; Do[c = Cyclotomic[n, 10]; q = c/GCD[c, n]; If[PrimeQ[q], AppendTo[lst, q]], {n, 62}]; Prepend[Sort[lst], 3] (* Arkadiusz Wesolowski, May 13 2012 *)

Formula

For n >= 2, a(n) = A019328(r) / gcd(A019328(r), r), where r = A051627(n). - Max Alekseyev, Oct 14 2022

Extensions

Missing term a(45) inserted in b-file at the suggestion of Eric Chen by Max Alekseyev, Oct 13 2022
Edited by Max Alekseyev, Oct 14 2022

A007498 Unique period lengths of primes mentioned in A007615.

Original entry on oeis.org

1, 2, 3, 4, 9, 10, 12, 14, 19, 23, 24, 36, 38, 39, 48, 62, 93, 106, 120, 134, 150, 196, 294, 317, 320, 385, 586, 597, 654, 738, 945, 1031, 1172, 1282, 1404, 1426, 1452, 1521, 1752, 1812, 1836, 1844, 1862, 2134, 2232, 2264, 2667, 3750, 3903, 3927, 4274, 4354
Offset: 1

Views

Author

Keywords

Comments

Let {Zs(m, 10, 1)} be the Zsigmondy numbers for a = 10, b = 1: Zs(m, 10, 1) is the greatest divisor of 10^m - 1^m that is coprime to 10^r - 1^r for all positive integers r < m. Then this sequence gives m such that Zs(m, 10, 1) is a prime power (e.g., Zs(1, 10, 1) = 9 = 3^2, Zs(2, 10, 1) = 11, Zs(3, 10, 1) = 37, Zs(4, 10, 1) = 101). It is very likely that Zs(m, 10, 1) is prime if m > 1 is in this sequence (note that the Mathematica and PARI programs below are based on this assumption). - Jianing Song, Aug 12 2020

References

  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
  • Samuel Yates, Period Lengths of Exactly One or Two Prime Numbers, J. Rec. Math., 18 (1985), 22-24.

Crossrefs

Cf. A161508 (unique period lengths in base 2).

Programs

  • Mathematica
    lst={1}; Do[p=Cyclotomic[n, 10]/GCD[n, Cyclotomic[n, 10]]; If[PrimeQ[p], AppendTo[lst, n]], {n, 3000}]; lst (* T. D. Noe, Sep 08 2005 *)
  • PARI
    isok(n) = if (n==1, 1, my(p = polcyclo(n, 10)); isprime(p/gcd(p, n))); \\ Michel Marcus, Jun 20 2018

Extensions

More terms from T. D. Noe, Sep 08 2005
a(48)-a(52) from Ray Chandler, Jul 09 2008

A007615 Primes with unique period length (the periods are given in A007498).

Original entry on oeis.org

3, 11, 37, 101, 333667, 9091, 9901, 909091, 1111111111111111111, 11111111111111111111111, 99990001, 999999000001, 909090909090909091, 900900900900990990990991, 9999999900000001, 909090909090909090909090909091, 900900900900900900900900900900990990990990990990990990990991
Offset: 1

Views

Author

Keywords

Comments

Additional terms are Phi(n,10)/gcd(n,Phi(n,10)) for the n in A007498, where Phi(n,10) is the n-th cyclotomic polynomial evaluated at 10.

Examples

			3 is the only prime p such that decimal expansion of 1/p has (nontrivial) period exactly 1.
		

References

  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
  • Samuel Yates, Period Lengths of Exactly One or Two Prime Numbers, J. Rec. Math., 18 (1985), 22-24.

Crossrefs

Programs

  • Mathematica
    nmax = 50; periods = Reap[ Do[ p = Cyclotomic[n, 10] / GCD[n, Cyclotomic[n, 10]]; If[ PrimeQ[p], Sow[n]], {n, 1, nmax}]][[2, 1]]; Cyclotomic[#, 10] / GCD[#, Cyclotomic[#, 10]]& /@ periods // Prepend[#, 3]& (* Jean-François Alcover, Mar 28 2013 *)

Formula

a(n) = A061075(A007498(n)). - Max Alekseyev, Oct 16 2010
a(n) = A006530(A019328(A007498(n))). - Ray Chandler, May 10 2017

A048963 Table in which n-th row lists digits in periodic part of decimal expansion of reciprocal of n-th prime.

Original entry on oeis.org

0, 3, 0, 1, 4, 2, 8, 5, 7, 0, 9, 0, 7, 6, 9, 2, 3, 0, 5, 8, 8, 2, 3, 5, 2, 9, 4, 1, 1, 7, 6, 4, 7, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 4, 3, 4, 7, 8, 2, 6, 0, 8, 6, 9, 5, 6, 5, 2, 1, 7, 3, 9, 1, 3, 0, 3, 4, 4, 8, 2, 7, 5, 8, 6, 2, 0, 6, 8, 9, 6, 5, 5, 1, 7, 2, 4, 1, 3, 7, 9, 3, 1
Offset: 1

Views

Author

Keywords

Comments

The length of row n is A048595(n). - T. D. Noe, May 14 2008
The convention is that the earliest period is displayed. - T. D. Noe, May 14 2008
Conjecture: regarded as a decimal fraction, this number is normal in base 10. - Franklin T. Adams-Watters, Aug 20 2012

Examples

			1/2=.5 ->0; 1/3=.3333... -> 3; 1/5=.2 ->0; 1/7=.142857... -> 1 4 2 8 5 7; etc.
0; 3; 0; 1,4,2,8,5,7; 0,9; 7,6,9,2,3,0; 5,8,8,2,3,5,2,9,4,1,1,7,6,4,7,0; ...
		

References

  • Conway and Guy, The Book of Numbers, p. 160

Crossrefs

Cf. A048962.

Programs

  • Mathematica
    Clear[d]; d[{{2|5}, 0}] = {0}; d[{{{n__}}, 0}] := {n}; d[{{{n__, 0}}, k_?Negative}] := Join[Table[0, {-k}], Drop[{n}, k+1]]; A048963 = d /@ RealDigits[1/Prime[Range[10]]] (* Jean-François Alcover, Dec 10 2014 *)

A060370 Ratios (p-1)/d, where p is a prime and d is the number of digits of the periodic part of the decimal expansion of 1/p.

Original entry on oeis.org

1, 2, 4, 1, 5, 2, 1, 1, 1, 1, 2, 12, 8, 2, 1, 4, 1, 1, 2, 2, 9, 6, 2, 2, 1, 25, 3, 2, 1, 1, 3, 1, 17, 3, 1, 2, 2, 2, 1, 4, 1, 1, 2, 1, 2, 2, 7, 1, 2, 1, 1, 34, 8, 5, 1, 1, 1, 54, 4, 10, 2, 2, 2, 2, 1, 4, 3, 1, 2, 3, 11, 2, 1, 2, 1, 1, 1, 4, 2, 2, 1, 3, 2, 1, 2
Offset: 1

Views

Author

Klaus Brockhaus, Apr 01 2001

Keywords

Comments

The sequence of 2nd, 4th and following terms coincides with A006556, which gives the "number of different cycles of digits in the decimal expansions of 1/p, 2/p, ..., (p-1)/p where p = n-th prime different from 2 or 5".

Examples

			a(13) = 40/5 = 8, since 41 is the 13th prime and the periodic part of 1/41 = 0.02439024390... consists of 5 digits.
		

Crossrefs

Programs

  • Mathematica
    Join[{1, 2, 4}, Table[p = Prime[n]; (p - 1)/Length[RealDigits[1/p, 10][[1, 1]]], {n, 4, 100}]] (* T. D. Noe, Oct 04 2012 *)
  • Python
    from sympy import prime, n_order
    def A060370(n): return 1 if n == 1 or n == 3 else n_order(10, prime(n))
    print([(prime(n)-1)//A060370(n) for n in range(1,86)]) # Karl-Heinz Hofmann, Mar 16 2022

Formula

a(n) = (b(n)-1)/c(n), where b(n) and c(n) are the n-th terms of A000040 and A048595 respectively.

A186635 Primes p such that the decimal expansion of 1/p has a periodic part of odd length.

Original entry on oeis.org

2, 3, 5, 31, 37, 41, 43, 53, 67, 71, 79, 83, 107, 151, 163, 173, 191, 199, 227, 239, 271, 277, 283, 307, 311, 317, 347, 359, 397, 431, 439, 443, 467, 479, 523, 547, 563, 587, 599, 613, 631, 643, 683, 719, 733, 751, 757, 773, 787, 797, 827, 839, 853, 883, 907, 911, 919, 947, 991, 1013, 1031, 1039, 1093, 1123, 1151, 1163, 1187
Offset: 1

Views

Author

Jani Melik, Feb 24 2011

Keywords

Comments

Interestingly, the initial terms of A040119 (Primes p such that x^4 = 10 has a solution mod p) are identical to the initial terms of this sequence except for 241 which is a term of A040119 but not of A186635. [John W. Layman, Feb 25 2011]
There are many numbers in A040119 that are not here: 241, 641, 769, 809, 1009, 1409, 1601, 1721.... - T. D. Noe, Feb 25 2011

Crossrefs

Cf. A002371, A048595, A028416 (complement in the primes), A040119.

Programs

  • Maple
    Ax := proc(n) local st:
    st := ithprime(n):
    if (modp(numtheory[order](10,st),2) <> 0) then
       RETURN(st)
    fi: end:  seq(Ax(n), n=1..200);
  • Mathematica
    Union[{2, 5}, Select[Prime[Range[200]], OddQ[Length[RealDigits[1/#][[1, 1]]]] &]]
  • PARI
    select( {is_A186635(n)=isprime(n) && (n<7 || znorder(Mod(10, n))%2)}, [0..1234]) \\ M. F. Hasler, Nov 19 2024
    
  • Python
    from sympy import isprime, n_order
    is_A186635 = lambda n: isprime(n) and (n<7 or n_order(10, n)%2)
    [n for n in range(1234) if is_A186635(n)] # M. F. Hasler, Nov 19 2024
Showing 1-10 of 12 results. Next