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-7 of 7 results.

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

A175555 Preperiodic part of the decimal expansion of 1/k as k runs through A065502.

Original entry on oeis.org

5, 25, 2, 1, 125, 1, 8, 0, 0, 625, 0, 5, 0, 41, 4, 0, 3, 0, 3125, 0, 0, 2, 0, 25, 0, 2, 0, 0, 208, 2, 1, 0, 0, 17, 0, 1, 0, 15625, 0, 0, 1, 0, 13, 0, 1, 1, 0, 125, 0, 1, 0, 0, 11, 0, 1, 0, 0, 1041, 0, 1
Offset: 1

Views

Author

Michel Lagneau, Jun 29 2010

Keywords

Comments

Multiples of 2 or 5 generate a quotient with a preperiodic sequence of digits, for example 1/24 = 0.041666666..., and 41 is the decimal form of the preperiodic part.
Usually a(n) = A114205(A065502(n)), but the convention in A114205 that leading zeros in the periodic part are attached to the preperiodic part seems not to be used here. - R. J. Mathar, Jul 20 2012

Examples

			a(14)=4 is in the sequence because 1/25 = 0.040000... and 4 is the prefix.
208 is in the sequence because 1/48 = 2083333.... and 208 is the prefix.
		

Crossrefs

Cf. A036275.

Programs

  • Maple
    A175555 := proc(n)
            local k,s,al ;
            k := A065502(n) ;
            for s from 1 do
                    for al from 0 to s-1 do
                            if (10^s-10^al) mod k = 0 then
                                    return floor(10^al/k) ;
                            end if;
                    end do:
            end do:
    end proc: # R. J. Mathar, Jul 22 2012

A114206 Length of the preperiodic part of the decimal expansion of 1/n, and also leading zeros from the period part if the preperiodic digits are all 0s (if any).

Original entry on oeis.org

1, 0, 2, 1, 1, 0, 3, 0, 1, 1, 2, 1, 1, 1, 4, 1, 1, 1, 2, 1, 1, 1, 3, 2, 1, 1, 2, 1, 1, 1, 5, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 4, 1, 2, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 6, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 2, 2, 1, 1, 1, 4, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 5, 1, 1, 1, 2
Offset: 2

Views

Author

N. J. A. Sloane, Oct 17 2006

Keywords

Comments

Differs from A386406 at n = 92, 208, 248...

Examples

			For n = 11, 1/n = 0.(09), so the preperiodic part is empty and the initial 0 of the periodic part is included for length a(11) = 1.
For n = 92, 1/n = 0.01(0869565217391304347826) , so the preperiodic part is "01" and has length a(92) = 2 and the initial 0 in the periodic part is not included since that preperiodic part is not all 0s (unlike the way A386406(92) = 3 does include that inat periodic initial 0).
		

Crossrefs

Programs

  • Mathematica
    fb[n_] := Block[{rd, o, p},rd = RealDigits[1/n];o = Last[rd];p = First[rd];If[ ! IntegerQ[Last[p]], p = Most[p]];Length[p] - o];Table[fb[n], {n, 120}] (* Ray Chandler, Oct 18 2006 *)
    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]]; b[x_]:=Which[IntegerQ[l[x]], Length[w[x]]-1*z[x], IntegerQ[f[x]]==False, -1*z[x], True, Length[Drop[w[x],-1]]-1*z[x]]; (* Hans Havermann, Oct 18 2006 *)
    Table[b[i], {i,2,128}]
  • PARI
    a(n) = max(logint(n,10), max(valuation(n,2), valuation(n,5))); \\ Kevin Ryde, Jul 22 2025

Formula

a(n) = max(A004216(n), A051628(n)). - Kevin Ryde, Jul 22 2025

Extensions

More terms from Ray Chandler and Hans Havermann, Oct 18 2006
Edited by Andrei Zabolotskii and Kevin Ryde, Jul 20 2025

A386406 Length of the preperiodic part of the decimal expansion of 1/n, including any leading zeros from the period.

Original entry on oeis.org

1, 0, 2, 1, 1, 0, 3, 0, 1, 1, 2, 1, 1, 1, 4, 1, 1, 1, 2, 1, 1, 1, 3, 2, 1, 1, 2, 1, 1, 1, 5, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 4, 1, 2, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 6, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 2, 2, 1, 1, 1, 4, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 3
Offset: 2

Views

Author

Andrei Zabolotskii, Jul 20 2025

Keywords

Comments

See A114205.

Examples

			For n = 92, 1/n = 0.01(0869565217391304347826) = 0.010(8695652173913043478260), so the preperiodic part is "010" and has length a(92) = 3.
		

Crossrefs

Programs

  • Mathematica
    b[n_] := Block[{p,o}, {p,o} = RealDigits[1/n]; If[!IntegerQ[Last[p]], p = Join[Most[p],TakeWhile[Last[p],#==0&]]]; Length[p]-o];
    Table[b[n], {n,2,100}]
  • PARI
    a(n) = my(pre = max(valuation(n,2),valuation(n,5)), r = 10^pre % n); pre + if(r,logint(n\r,10)); \\ Kevin Ryde, Jul 22 2025

Formula

a(n) = p + (floor(log_10(1/f)) if f!=0), where p = A051628(n) and f = frac(10^p/n). - Kevin Ryde, Jul 22 2025

A235589 The periodic part of the decimal expansion of m/(m+1), for those m/(m+1) that have pure periods.

Original entry on oeis.org

6, 857142, 8, 90, 923076, 9411764705882352, 947368421052631578, 952380, 9565217391304347826086, 962, 9655172413793103448275862068, 967741935483870, 96, 972, 974358, 97560, 976744186046511627906, 9787234042553191489361702127659574468085106382, 979591836734693877551020408163265306122448
Offset: 1

Views

Author

Bill McEachen, Jan 12 2014

Keywords

Comments

A companion sequence stemming from the some of the elements excluded by A156703. The sequence is highly volatile and infinite...as with A156703 the subset elements are encountered in numerical order. a(n) will start with the digit 9 for n>4 I believe. Entries can grow quite large very quickly. Each entry will be encountered once, and they will end in an even digit.
The number of digits of a(n) is given by A002329. - Michel Marcus, Aug 19 2015

Examples

			1/2=0.5 non-repeating, so exclude from sequence.
2/3=0.6 repeating, so a(1)=6.
5/6=0.833 (repeating) but has "8" prefix ahead of repeating "3" so exclude from sequence (decimal expansion not purely periodic)
6/7=0.857142 repeating so a(2)=857142.
		

Crossrefs

Subsequence of A259299.

Programs

  • Mathematica
    FromDigits@ Flatten@ First@ RealDigits[(# - 1)/#] & /@ Select[Range@ 120, CoprimeQ[#, 10] &] //Rest (* Michael De Vlieger, Aug 18 2015 *)

Formula

a(n) = the periodic part of the decimal expansion of (A045572(n+1)-1) / A045572(n+1). - Doug Bell, Aug 17 2015

Extensions

Missing terms added by Ralf Stephan, Jan 19 2014
Incorrect terms 916, 94 removed and two more terms added by Michael De Vlieger, Aug 18 2015

A291943 a(0)=0; for n>0, a(n) = (2n)-th digit after the decimal point in the decimal expansion of 1/(2n+1).

Original entry on oeis.org

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

Views

Author

Marco Matosic, Sep 06 2017

Keywords

Examples

			a(3)=7 since we want the sixth decimal digit of 1/7.
		

References

  • John H. Conway & Richard K. Guy, The Book of Numbers; Springer 1996.

Crossrefs

Programs

  • Maple
    f:= proc(n) floor(10^(2*n)/(2*n+1)) mod 10 end proc:
    f(0):= 0:
    map(f, [$0..100]); # Robert Israel, Oct 31 2017
  • Mathematica
    f[n_] := Mod[Floor[10^(2n)/(2n +1)], 10]; f[0] = 0; Array[f, 105, 0] (* Robert G. Wilson v, Oct 31 2017 *)

Extensions

Edited by N. J. A. Sloane, Oct 30 2017
a(82) corrected by Robert Israel, Oct 31 2017

A307070 a(n) is the number of decimal places before the decimal expansion of 1/n terminates, or the period of the recurring portion of 1/n if it is recurring.

Original entry on oeis.org

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

Views

Author

Luke W. Richards, Mar 22 2019

Keywords

Comments

If the decimal expansion of 1/n terminates, we will write it as ending with infinitely many 0's (rather than 9's). Then for any n > 1, the expansion of 1/n consists of a preamble whose length is given by A051628(n), followed by a periodic part with period length A007732(n). This sequence is defined as follows: If the only primes dividing n are 2 and 5 (see A003592), a(n) = A051628(n), otherwise a(n) = A007732(n) (and the preamble is ignored). - N. J. A. Sloane, Mar 22 2019
This sequence was discovered by a school class (aged 12-13) at Arden School, Solihull, UK.
Equally space the digits 0-9 on a circle. The digits of the decimal expansion of rational numbers can be connected on this circle to form data visualizations. This sequence is useful, cf. A007732 or A051626, for identifying the complexity of that visualization.

Examples

			1/1 is 1.0. There are no decimal digits, so a(1) = 0.
1/2 is 0.5. This is a terminating decimal. There is 1 digit, so a(2) = 1.
1/6 is 0.166666... This is a recurring decimal with a period of 1 (the initial '1' does not recur) so a(6) = 1.
1/7 is 0.142857142857... This is a recurring decimal, with a period of 6 ('142857') so a(7) = 6.
		

Crossrefs

See A114205 and A051628 for the preamble, A036275 and A051626 for the periodic part.

Programs

  • PARI
    a(n) = my (t=valuation(n,2), f=valuation(n,5), r=n/(2^t*5^f)); if (r==1, max(t,f), znorder(Mod(10, r))) \\ Rémy Sigrist, May 08 2019
  • Python
    def sequence(n):
      count = 0
      dividend = 1
      remainder = dividend % n
      remainders = [remainder]
      no_recurrence = True
      while remainder != 0:
        count += 1
        dividend = remainder * 10
        remainder = dividend % n
        if remainder in remainders:
          if no_recurrence:
            no_recurrence = False
            remainders = [remainder]
          else:
            return len(remainders)
        else:
          remainders.append(remainder)
      else:
        return count
    

Extensions

More terms from Rémy Sigrist, May 08 2019
Showing 1-7 of 7 results.