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

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

A054710 Number of powers of 10 mod n.

Original entry on oeis.org

1, 2, 1, 3, 2, 2, 6, 4, 1, 2, 2, 3, 6, 7, 2, 5, 16, 2, 18, 3, 6, 3, 22, 4, 3, 7, 3, 8, 28, 2, 15, 6, 2, 17, 7, 3, 3, 19, 6, 4, 5, 7, 21, 4, 2, 23, 46, 5, 42, 3, 16, 8, 13, 4, 3, 9, 18, 29, 58, 3, 60, 16, 6, 7, 7, 3, 33, 18, 22, 7, 35, 4, 8, 4, 3, 20, 6, 7, 13, 5, 9, 6, 41, 8, 17, 22, 28, 5, 44, 2
Offset: 1

Views

Author

Henry Bottomley, Apr 20 2000

Keywords

Crossrefs

Cf. A054703 (base 2), A054704 (3), A054705 (4), A054706 (5), A054707 (6), A054708 (7), A054709 (8), A054717 (9), A351524 (11), A054712 (12), A054713 (13), A054714 (14), A054715 (15), A054716 (16).

Programs

  • Mathematica
    Table[Length[Union[PowerMod[10, Range[0,n], n]]], {n,100}] (* T. D. Noe, Aug 30 2006 *)
    a[n_] := Module[{e = IntegerExponent[n, {2, 5}]}, Max[e] + MultiplicativeOrder[10, n/Times @@ ({2, 5}^e)]]; Array[a, 100] (* Amiram Eldar, Aug 25 2024 *)

Formula

a(n) = A007732(n) + A051628(n). - Amiram Eldar, Aug 25 2024

A065502 Positive numbers divisible by 2 or 5; 1/n not purely periodic after decimal point.

Original entry on oeis.org

2, 4, 5, 6, 8, 10, 12, 14, 15, 16, 18, 20, 22, 24, 25, 26, 28, 30, 32, 34, 35, 36, 38, 40, 42, 44, 45, 46, 48, 50, 52, 54, 55, 56, 58, 60, 62, 64, 65, 66, 68, 70, 72, 74, 75, 76, 78, 80, 82, 84, 85, 86, 88, 90, 92, 94, 95, 96, 98, 100, 102, 104, 105, 106, 108, 110, 112, 114
Offset: 1

Views

Author

Len Smiley, Nov 25 2001

Keywords

Comments

Complement of A045572. - Reinhard Zumkeller, Nov 15 2009
Numbers that cannot be prefixed by a single digit to form a prime in decimal representation: A124665 is a subsequence. - Reinhard Zumkeller, Oct 22 2011
Up to 198, this is almost identical to "a(n) = n such that 3^n-1 is not squarefree", with the only exceptions being 39 and 117, which are not in this sequence. Why is that? - Felix Fröhlich, Oct 19 2014
The asymptotic density of this sequence is 3/5. - Amiram Eldar, Mar 09 2021

Crossrefs

Cf. A000035, A001622, A045572, A051628, A079998, A124665, A047229 (numbers divisible by 2 or 3).

Programs

  • Haskell
    a065502 n = a065502_list !! (n-1)
    a065502_list = filter ((> 1) . (gcd 10)) [1..]
    -- Reinhard Zumkeller, Oct 22 2011
  • Maple
    A065502 := proc(n)
         option remember;
         if n = 1 then
            2;
        else
            for a from procname(n-1)+1 do
                if (a mod 2) =0 or (a mod 5) =0 then
                    return a;
                end if;
            end do:
        end if;
    end proc; # R. J. Mathar, Jul 20 2012
  • Mathematica
    Select[Range[114], Mod[#, 2] == 0 || Mod[#, 5] == 0 &] (* T. D. Noe, Jul 13 2012 *)
    Select[ Range@ 114, MemberQ[{0, 2, 4, 5, 6, 8}, Mod[#, 10]] &] (* Robert G. Wilson v, May 22 2014 *)
  • PARI
    isok(m) = ! ((m%2) && (m%5)); \\ Michel Marcus, Mar 09 2021
    

Formula

A000035(a(n))*(1-A079998(a(n)))=0. - Reinhard Zumkeller, Nov 15 2009
G.f.: x*(2*x^4+x^2+2) / ((x-1)^2*(x^2-x+1)*(x^2+x+1)). - Colin Barker, Jul 18 2013
a(n) = 10*floor(n/6)+s(n mod 6)-floor(((n-1)mod 6)/5), where s(n) = n+1+floor((n+1)/3). - Gary Detlefs, Oct 05 2013
Sum_{n>=1} (-1)^(n+1)/a(n) = log(2)/5 + log(phi)/sqrt(5), where phi is the golden ratio (A001622). - Amiram Eldar, Dec 28 2021

Extensions

Offset changed from 0 to 1 by Harry J. Smith, Oct 20 2009

A121341 Number of decimal places before 1/n either recurs or terminates.

Original entry on oeis.org

0, 1, 1, 2, 1, 2, 6, 3, 1, 1, 2, 3, 6, 7, 2, 4, 16, 2, 18, 2, 6, 3, 22, 4, 2, 7, 3, 8, 28, 2, 15, 5, 2, 17, 7, 3, 3, 19, 6, 3, 5, 7, 21, 4, 2, 23, 46, 5, 42, 2, 16, 8, 13, 4, 3, 9, 18, 29, 58, 3, 60, 16, 6, 6, 7, 3, 33, 18, 22, 7, 35, 4, 8, 4, 3, 20, 6, 7, 13, 4, 9, 6, 41, 8, 17, 22, 28, 5, 44, 2, 6
Offset: 1

Views

Author

Anthony C Robin, Aug 29 2006

Keywords

Comments

In this sequence, the repeating decimals (e.g., 1/7) are treated differently from nonrepeating decimals (e.g., 1/5). If they are treated the same, then a(2)=2, a(4)=3, a(5)=2, a(8)=4, a(10)=2, ... and we obtain A054710. The two sequence differ only for n = 2^j * 5^k.

Examples

			1/592 = 0.0016891891891... starts with 4 decimals (0016, zeros counted) and has period 3 (digits 891) to yield a(592) = 4 + 3 = 7.
		

Crossrefs

A007732 is the length of the periods and serves as a lower bound. Cf. A061075.

Programs

  • Mathematica
    a[n_] := Max[IntegerExponent[n, 2], IntegerExponent[n, 5]] + Length[RealDigits[1/n][[1, -1]]];
    Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Jul 20 2022 *)

Formula

a(n) = A051628(n) + A051626(n). - Sean A. Irvine, Apr 13 2022

Extensions

More terms from T. D. Noe, Aug 30 2006
Additional comments from R. J. Mathar, Aug 30 2006

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

A276981 Irregular triangle T(n,k) read by rows of residue classes of powers of 10 modulo n.

Original entry on oeis.org

0, 1, 0, 1, 1, 2, 0, 1, 0, 1, 4, 1, 3, 2, 6, 4, 5, 1, 2, 4, 0, 1, 1, 0, 1, 10, 1, 10, 4, 1, 10, 9, 12, 3, 4, 1, 10, 2, 6, 4, 12, 8, 1, 10, 1, 10, 4, 8, 0, 1, 10, 15, 14, 4, 6, 9, 5, 16, 7, 2, 3, 13, 11, 8, 12, 1, 10, 1, 10, 5, 12, 6, 3, 11, 15, 17, 18, 9, 14, 7, 13, 16, 8, 4, 2
Offset: 1

Views

Author

Martin Renner, Apr 11 2017

Keywords

Comments

The length of the nonperiodic part of the residue class values is given in A051628, the length of the periodic part is given in A007732.
These residue class values are useful to check the divisibility of a number by the divisor n simply by calculating the weighted sum of digits. For example, the number 86415 is divisible by 7, because the weighted sum of digits 5*1 + 1*3 + 4*2 + 6*6 + 8*4 = 84 is divisible by 7. The used weights are the residue class values for n = 7: 1, 3, 2, 6, 4, 5, ... for ones, tens, hundreds, ...

Examples

			T(n,k), 1 <= k <= A051628(n) + A007732(n), starts with
n = 1:  0
n = 2:  1, 0
n = 3:  1
n = 4:  1, 2, 0
n = 5:  1, 0
n = 6:  1, 4
n = 7:  1, 3, 2, 6, 4, 5
n = 8:  1, 2, 4, 0
n = 9:  1
n = 10: 1, 0
n = 11: 1, 10
n = 12: 1, 10, 4
etc.
		

Crossrefs

Programs

  • Maple
    a:=proc(n)
      local R,N,P,i;
      R:=[seq(10^k mod n,k=0..n)]; # residue class
      N:=[]; # nonperiodic part
      P:=[]; # periodic part
      for i from 1 to nops(R) do
        member(R[i],R,'m');
        if m
    				

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

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

A357756 a(n) is the least k > 0 such that A007953(n*k) equals A007953((n*k)^2), where A007953 is the sum of the digits.

Original entry on oeis.org

1, 1, 5, 3, 25, 2, 3, 27, 62, 1, 1, 5, 15, 27, 128, 3, 31, 17, 1, 1, 5, 9, 9, 2, 75, 4, 18, 7, 64, 5, 3, 16, 56, 3, 85, 17, 5, 27, 5, 9, 25, 9, 45, 13, 27, 1, 1, 27, 66, 54, 2, 9, 9, 18, 22, 1, 32, 15, 25, 135, 3, 18, 8, 3, 28, 9, 3, 43, 47, 72, 27, 8, 25, 126, 27
Offset: 0

Author

Thomas Scheuerle, Oct 12 2022

Keywords

Comments

A task in the German competition "Bundeswettbewerb Mathematik 2021" was to prove that for each positive integer n there exists a k such that A007953(n*k) = A007953((n*k)^2).
One of the proposed proofs uses the argument that numbers of the form m = (10^x-1)*(10^y) will have the desired property A007953(m) = A007953(m^2). Thus we need to prove that we can find for all n a k, x and y such that n*k = (10^x-1)*(10^y). Let n be of the form b*2^c*5^d with b odd and not divisible by 5, then we know that y = max(c, d). From Euler's totient theorem we know that 10^x-1 will be divisible by e if x = A000010(e) where A000010 is Euler's totient function. See the formula section for the corresponding resulting k.
a(n) will never be divisible by 10.
If n is divisible by 3 but not by 9, then a(n) is divisible by 3. - Robert Israel, Oct 13 2022

Programs

  • Maple
    f:= proc(n) local k;
       for k from 1 do if sd(n*k) = sd((n*k)^2) then return k fi od
    end proc:
    map(f, [$1..100]); # Robert Israel, Oct 13 2022
  • PARI
    a(n) = {my(k = 1); while(sumdigits(n*k)!=sumdigits((n*k)^2),k++);k}
    
  • Python
    def sd(n): return sum(map(int, str(n)))
    def a(n):
        k = 1
        while not sd(n*k) == sd((n*k)**2): k += 1
        return k
    print([a(n) for n in range(75)]) # Michael S. Branicky, Oct 13 2022

Formula

a(A058369(n)) = 1.
a(a(n)) <= n.
a(n) <= A132740(n)*A060284(A132740(n))*10^A051628(n)/n.
or a(n) <= (10^A000010(A132740(n))-1)*10^A051628(n)/n.

A384869 For n >= 1, a(n) = Sum_{k = 1..n} gcd(n, floor((n/k)*10^x)), where x = A121341(k/gcd(n,k)).

Original entry on oeis.org

1, 3, 7, 8, 17, 21, 31, 27, 53, 33, 71, 58, 85, 74, 103, 75, 129, 118, 145, 70, 209, 141, 199, 146, 197, 194, 309, 191, 281, 175, 301, 206, 427, 271, 339, 297, 397, 306, 503, 157, 481, 432, 505, 336, 559, 395, 553, 388, 607, 303, 777, 454, 677, 620, 605, 467
Offset: 1

Author

Ctibor O. Zizka, Jun 11 2025

Keywords

Comments

a(n) < n^2 - n + 1.

Examples

			For n = 12:
k = 4, x = A121341(4/gcd(12,4)) = 0, gcd(12, floor((12/4)*10^0)) = 3;
k = 5, x = A121341(5/gcd(12,5)) = 1, gcd(12, floor((12/5)*10^1)) = 12;
and so on.
		

Programs

  • Mathematica
    f[n_] := Max[IntegerExponent[n, 2], IntegerExponent[n, 5]] + Length[RealDigits[1/n][[1, -1]]]; a[n_] := Sum[GCD[n, Floor[(n/k)*10^f[k/GCD[n, k]]]], {k, 1, n}]; Array[a, 100] (* Amiram Eldar, Jun 19 2025 *)
Showing 1-10 of 10 results.