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.

Previous Showing 21-30 of 118 results. Next

A055017 Difference between sums of alternate digits of n starting with the last, i.e., (sum of ultimate digit of n, antepenultimate digit of n, ...) - (sum of penultimate digit of n, preantepenultimate digit of n, ...).

Original entry on oeis.org

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

Views

Author

Henry Bottomley, May 31 2000

Keywords

Comments

a(n) is a multiple of 11 iff n is divisible by 11.
Digital sum with alternating signs starting with a positive sign for the rightmost digit. - Hieronymus Fischer, Jun 18 2007
For n < 100, a(n) = (n mod 10 - floor(n/10)) = -A076313(n). - Hieronymus Fischer, Jun 18 2007

Examples

			a(123) = 3-2+1 = 2, a(9875) = 5-7+8-9 = -3.
		

Crossrefs

Cf. A225693 (alternating sum of digits).
Unsigned version differs from A040114 and A040115 when n=100 and from A040997 when n=101.
Cf. A004086.
Cf. analogous sequences for bases 2-9: A065359, A065368, A346688, A346689, A346690, A346691, A346731, A346732 and also A373605 (for primorial base).

Programs

  • Maple
    sumodigs := proc(n) local dg; dg := convert(n,base,10) ; add(op(1+2*i,dg), i=0..floor(nops(dg)-1)/2) ; end proc:
    sumedigs := proc(n) local dg; dg := convert(n,base,10) ; add(op(2+2*i,dg), i=0..floor(nops(dg)-2)/2) ; end proc:
    A055017 := proc(n) sumodigs(n)-sumedigs(n) ; end proc: # R. J. Mathar, Aug 26 2011
  • Python
    def A055017(n): return sum((-1 if i % 2 else 1)*int(j) for i, j in enumerate(str(n)[::-1])) # Chai Wah Wu, May 11 2022
  • Smalltalk
    "Recursive version for general bases"
    "Set base = 10 for this sequence"
    altDigitalSumRight: base
    | s |
    base = 1 ifTrue: [^self \\ 2].
    (s := self // base) > 0
      ifTrue: [^(self - (s * base) - (s altDigitalSumRight: base))]
      ifFalse: [^self]
    [by Hieronymus Fischer, Mar 23 2014]
    

Formula

From Hieronymus Fischer, Jun 18 2007, Jun 25 2007, Mar 23 2014: (Start)
a(n) = n + 11*Sum_{k>=1} (-1)^k*floor(n/10^k).
a(10n+k) = k - a(n), 0 <= k < 10.
G.f.: Sum_{k>=1} (x^k-x^(k+10^k)+(-1)^k*11*x^(10^k))/((1-x^(10^k))*(1-x)).
a(n) = n + 11*Sum_{k=10..n} Sum_{j|k,j>=10} (-1)^floor(log_10(j))*(floor(log_10(j)) - floor(log_10(j-1))).
G.f. expressed in terms of Lambert series: g(x) = (x/(1-x)+11*L[b(k)](x))/(1-x) where L[b(k)](x) = Sum_{k>=0} b(k)*x^k/(1-x^k) is a Lambert series with b(k) = (-1)^floor(log_10(k)) if k>1 is a power of 10, otherwise b(k)=0.
G.f.: (1/(1-x)) * Sum_{k>=1} (1+11*c(k))*x^k, where c(k) = Sum_{j>=2,j|k} (-1)^floor(log_10(j))*(floor(log_10(j))-floor(log_10(j-1))).
Formulas for general bases b > 1 (b = 10 for this sequence).
a(n) = Sum_{k>=0} (-1)^k*(floor(n/b^k) mod b).
a(n) = n + (b+1)*Sum_{k>=1} (-1)^k*floor(n/b^k). Both sums are finite with floor(log_b(n)) as the highest index.
a(n) = a(n mod b^k) + (-1)^k*a(floor(n/b^k)), for all k >= 0.
a(n) = a(n mod b) - a(floor(n/b)).
a(n) = a(n mod b^2) + a(floor(n/b^2)).
a(n) = (-1)^m*A225693(n), where m = floor(log_b(n)).
a(n) = (-1)^k*A225693(A004086(n)), where k = is the number of trailing 0's of n, formally, k = max(j | n == 0 (mod 10^j)).
a(A004086(A004086(n))) = (-1)^k*a(n), where k = is the number of trailing 0's in the decimal representation of n. (End)

A055013 Sum of 4th powers of digits of n.

Original entry on oeis.org

0, 1, 16, 81, 256, 625, 1296, 2401, 4096, 6561, 1, 2, 17, 82, 257, 626, 1297, 2402, 4097, 6562, 16, 17, 32, 97, 272, 641, 1312, 2417, 4112, 6577, 81, 82, 97, 162, 337, 706, 1377, 2482, 4177, 6642, 256, 257, 272, 337, 512, 881, 1552, 2657, 4352, 6817
Offset: 0

Views

Author

Henry Bottomley, May 31 2000

Keywords

Comments

Fixed points are listed in A052455, row 4 of A252648. See also A061210. - M. F. Hasler, Apr 12 2015

Crossrefs

Programs

  • Magma
    [0] cat [&+[d^4: d in Intseq(n)]: n in [1..50]]; // Bruno Berselli, Feb 01 2013
    
  • Maple
    A055013 := proc(n)
            add(d^4,d=convert(n,base,10)) ;
    end proc:
    seq(A055013(n),n=0..20) ; # R. J. Mathar, Nov 07 2011
  • Mathematica
    Table[Sum[DigitCount[n][[i]] i^4, {i, 9}], {n, 0, 50}] (* Bruno Berselli, Feb 01 2013 *)
    Table[Total[IntegerDigits[n]^4],{n,0,50}] (* Harvey P. Dale, Jul 28 2019 *)
  • PARI
    a(n)=round(normlp(n,4)^4) \\ Quite slow. - M. F. Hasler, Apr 12 2015
    
  • PARI
    A055013(n)=sum(i=1,#n=digits(n),n[i]^4) \\ M. F. Hasler, Apr 12 2015

Formula

a(n) = sum{k>0, (floor(n/10^k)-10*floor(n/10^(k+1)))^4}. - Hieronymus Fischer, Jun 25 2007
a(10n+k) = a(n)+k^4, 0<=k<10. - Hieronymus Fischer, Jun 25 2007

A031177 Unhappy numbers: numbers having period-8 2-digitized sequences.

Original entry on oeis.org

2, 3, 4, 5, 6, 8, 9, 11, 12, 14, 15, 16, 17, 18, 20, 21, 22, 24, 25, 26, 27, 29, 30, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 47, 48, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 69, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 83
Offset: 1

Views

Author

Keywords

Crossrefs

Complement of happy numbers A007770. Cf. A056527.

Programs

  • Haskell
    a031177 n = a031177_list !! (n-1)
    a031177_list = filter ((/= 1) . a103369) [1..]
    -- Reinhard Zumkeller, Aug 24 2011
    
  • Python
    from itertools import count, islice
    def A031177_gen(startvalue=1): # generator of terms >= startvalue
        for n in count(max(startvalue,1)):
            m = n
            while m not in {1,37,58,89,145,42,20,4,16}:
                m = sum((0, 1, 4, 9, 16, 25, 36, 49, 64, 81)[ord(d)-48] for d in str(m))
            if m > 1:
                yield n
    A031177_list = list(islice(A031177_gen(),20)) # Chai Wah Wu, Aug 02 2023

A039943 Every integer eventually goes to one of these under the "x goes to sum of squares of digits of x" map.

Original entry on oeis.org

0, 1, 4, 16, 20, 37, 42, 58, 89, 145
Offset: 0

Views

Author

Keywords

Comments

The subset of the first three terms also satisfies the current definition. An alternate definition would be: Periodic points of A003132. - M. F. Hasler, May 24 2009
Following I. Ja. Tanatar (Moscow), one can easily prove that, for a given x, there exists an iteration of the map f(x) given in the definition which reaches 1 or 89. Indeed, it is easy to see that if x has at least 3 digits, then f(x) < x. Therefore there exists an iteration of f with not more than 2 digits. For two-digit numbers the property is verified directly. See Kordemsky. - Vladimir Shevelev, May 06 2013

References

  • B. A. Kordemsky, Matematicheskaja Smekalka, Moscow, 1955, pp. 305 and 557 (in Russian).

Crossrefs

Cf. A003132 (the iterated map), A003621, A039943, A031176, A007770, A000216 (orbit of 2), A000218 (orbit of 3), A080709 (orbit of 4, the only nontrivial limit cycle), A000221 (orbit of 5), A008460 (orbit of 6), A008462 (orbit of 8), A008463 (orbit of 9), A139566 (orbit of 15), A122065 (orbit of 74169).

Programs

  • Haskell
    a039943 n = a039943_list !! n
    a039943_list = [0,1,4,16,20,37,42,58,89,145]
    -- Reinhard Zumkeller, Mar 16 2013
  • Mathematica
    lst = {}; Do[a = NestWhile[Plus @@ (IntegerDigits@#^2) &, n, Unequal, All]; If[FreeQ[lst, a], AppendTo[lst, a]], {n, 10^4}] (* Robert G. Wilson v, Jan 19 2006 *)
    Union[Table[NestWhile[Total[IntegerDigits[#]^2]&,n,Unequal,All],{n,0,100}]] (* Harvey P. Dale, Nov 26 2013 *)

A000216 Take sum of squares of digits of previous term, starting with 2.

Original entry on oeis.org

2, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37
Offset: 1

Views

Author

Keywords

Comments

As the orbit of 2 under A003132, this could also have offset 0. Merges into A080709 right after the first term: a(n+1) = A080709(n) for all n >= 1. - M. F. Hasler, Apr 27 2018

References

  • R. Honsberger, Ingenuity in Mathematics, Random House, 1970, p. 83.
  • P. Kiss, A generalization of a problem in number theory, Math. Sem. Notes Kobe Univ., 5 (1977), no. 3, 313-317. MR 0472667 (57 #12362).

Crossrefs

Cf. A003132 (the iterated map), A003621, A039943, A099645, A031176, A007770, A000218 (starting with 3), A080709 (starting with 4), A000221 (starting with 5), A008460 (starting with 6), A008462 (starting with 8), A008463 (starting with 9), A139566 (starting with 15), A122065 (starting with 74169). - M. F. Hasler, May 24 2009

Programs

  • Haskell
    a000216 n = a000216_list !! (n-1)
    a000216_list = iterate a003132 2 -- Reinhard Zumkeller, Aug 24 2011
    
  • Magma
    [2] cat &cat[[4, 16, 37, 58, 89, 145, 42, 20]: n in [0..17]]; // Vincenzo Librandi, Jan 29 2013
  • Mathematica
    NestList[Total[IntegerDigits[#]^2]&, 2, 80] (* Vincenzo Librandi, Jan 29 2013 *)
  • PARI
    A000216(n)=[42, 20, 4, 16, 37, 58, 89, 145, 2][n%8+8^(n<2)] \\ M. F. Hasler, May 24 2009, edited Apr 27 2018
    

Formula

Periodic with period 8.

A055014 Sum of 5th powers of digits of n.

Original entry on oeis.org

0, 1, 32, 243, 1024, 3125, 7776, 16807, 32768, 59049, 1, 2, 33, 244, 1025, 3126, 7777, 16808, 32769, 59050, 32, 33, 64, 275, 1056, 3157, 7808, 16839, 32800, 59081, 243, 244, 275, 486, 1267, 3368, 8019, 17050, 33011, 59292, 1024, 1025, 1056, 1267, 2048
Offset: 0

Views

Author

Henry Bottomley, May 31 2000

Keywords

Comments

Fixed points are listed in A052464. - M. F. Hasler, Apr 12 2015

Crossrefs

Programs

  • Magma
    [0] cat [&+[d^5: d in Intseq(n)]: n in [1..45]]; // Bruno Berselli, Feb 01 2013
    
  • Maple
    A055014 := proc(n)
       add(d^5,d=convert(n,base,10)) ;
    end proc: # R. J. Mathar, Jul 08 2012
  • Mathematica
    Total/@(IntegerDigits[Range[50]]^5)  (* Harvey P. Dale, Jan 22 2011 *)
    Table[Sum[DigitCount[n][[i]] i^5, {i, 9}], {n, 0, 45}] (* Bruno Berselli, Feb 01 2013 *)
  • PARI
    A055014(n)=sum(i=1, #n=digits(n), n[i]^5) \\ M. F. Hasler, Apr 12 2015

Formula

a(n) = Sum_{k>=1} (floor(n/10^k) - 10*floor(n/10^(k+1)))^5. - Hieronymus Fischer, Jun 25 2007
a(10n+k) = a(n) + k^5, 0 <= k < 10. - Hieronymus Fischer, Jun 25 2007

A031176 Periods of sum of squares of digits iterated until the sequence becomes periodic.

Original entry on oeis.org

1, 1, 8, 8, 8, 8, 8, 1, 8, 8, 1, 8, 8, 1, 8, 8, 8, 8, 8, 1, 8, 8, 8, 1, 8, 8, 8, 8, 1, 8, 8, 1, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 8, 8, 8, 8, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 8, 1, 8, 8, 8, 8, 8, 8, 8, 8, 1, 8, 8, 1, 8, 8, 8, 1, 8, 8, 8, 8, 1, 8, 8, 1, 8, 8, 1, 8, 8
Offset: 0

Views

Author

Keywords

Crossrefs

Cf. A003132, A099645. [From R. J. Mathar, May 31 2009]

Extensions

The value a(0)=1 was added by R. J. Mathar, May 31 2009

A052034 Primes such that the sum of the squares of their digits is also a prime.

Original entry on oeis.org

11, 23, 41, 61, 83, 101, 113, 131, 137, 173, 179, 191, 197, 199, 223, 229, 311, 313, 317, 331, 337, 353, 373, 379, 397, 401, 409, 443, 449, 461, 463, 467, 601, 641, 643, 647, 661, 683, 719, 733, 739, 773, 797, 829, 863, 883, 911, 919, 937, 971, 977, 991, 997, 1013
Offset: 1

Views

Author

Patrick De Geest, Dec 15 1999

Keywords

Comments

Primes p such that the sum of the squared digits of p is a prime q. For the values of q see A109181.

Examples

			p = 23 is in the sequence because q = 2^2 + 3^2 = 13 is a prime.
9431 -> 9^2 + 4^2 + 3^2 + 1^2 = 107 (which is prime).
		

References

  • Clifford A. Pickover, A Passion for Mathematics, John Wiley & Sons, Inc., 2005, p. 89.
  • Charles W. Trigg, Journal of Recreational Mathematics, Vol. 20(2), 1988.

Crossrefs

Programs

  • Maple
    a:=proc(n) local nn, L: nn:=convert(n,base,10): L:=nops(nn): if isprime(n)= true and isprime(add(nn[j]^2,j=1..L))=true then n else end if end proc: seq(a(n),n=1..1000); # Emeric Deutsch, Jan 08 2008
  • Mathematica
    Select[Prime[Range[250]],PrimeQ[Total[IntegerDigits[#]^2]]&]  (* Harvey P. Dale, Dec 19 2010 *)
  • Python
    from sympy import isprime, primerange
    def ok(p): return isprime(sum(int(d)**2 for d in str(p)))
    def aupto(limit): return [p for p in primerange(1, limit+1) if ok(p)]
    print(aupto(1013)) # Michael S. Branicky, Nov 23 2021

Extensions

Edited by N. J. A. Sloane, Dec 15 2007 and again on Dec 05 2008 at the suggestion of Zak Seidov

A000218 Take sum of squares of digits of previous term; start with 3.

Original entry on oeis.org

3, 9, 81, 65, 61, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37
Offset: 1

Views

Author

Keywords

Comments

Could also have offset 0, considered as the orbit of 3 under A003132, i.e., n-fold application of A003132 on the initial value 3. - M. F. Hasler, Apr 27 2018

References

  • R. Honsberger, Ingenuity in Math., Random House, 1970, p. 83.

Crossrefs

Cf. A003132 (the iterated map), A003621, A039943, A099645, A031176, A007770, A000216 (starting with 2), A080709 (starting with 4), A000221 (starting with 5), A008460 (starting with 6), A008462 (starting with 8), A008463 (starting with 9), A139566 (starting with 15), A122065 (starting with 74169). - M. F. Hasler, May 24 2009

Programs

  • Haskell
    a000218 n = a000218_list !! (n-1)
    a000218_list = iterate a003132 3
    -- Reinhard Zumkeller, Aug 24 2011
    
  • Magma
    [3, 9, 81, 65, 61] cat &cat[[37, 58, 89, 145, 42, 20, 4, 16]: n in [0..17]]; // Vincenzo Librandi, Jan 29 2013
  • Mathematica
    NestList[Total[IntegerDigits[#]^2]&, 3, 80] (* Vincenzo Librandi, Jan 29 2013 *)
  • PARI
    A000218(n)=[89, 145, 42, 20, 4, 16, 37, 58, 3, 9, 81, 65, 61][n%8+8^(n<6)] \\ M. F. Hasler, May 24 2009, edited Apr 27 2018
    

Formula

Eventually periodic with period 8.

A099645 Number of iterations until n reaches a number in A039943 under "x goes to sum of squares of digits of x" map.

Original entry on oeis.org

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

Views

Author

Labos Elemer, Nov 08 2004

Keywords

Comments

Length of transient when the f[n]=Sum[digit^2 of n] function is iterated.
In A031176 including cycle lengths[=c] of this iteration only c=1 and c=8 occur. A007770 lists cases of c=1, the happy numbers.

Examples

			n=99999999999: iteration-list={99999999999,891,146,53,34,25,29,85,89,145,42,20,[4,16,37,58,89,145,42,20],4,...}. Lengths of transient=12, of cycle=8.
		

References

  • Hugo Steinhaus: "Sto zadan" (1958), "One Hundred Problems in Elementary Mathematics" (1964), problem 2. - M. F. Hasler, May 24 2009

Crossrefs

Cf. A039943, A031176, A007770, A000216 (orbit of 2), A000218 (orbit of 3), A080709 (orbit of 4), A000221 (orbit of 5), A008460 (orbit of 6), A008462 (orbit of 8), A008463 (orbit of 9), A139566 (orbit of 15), A122065 (orbit of 74169). - M. F. Hasler, May 24 2009

Programs

  • Haskell
    a099645 = length . takeWhile (`notElem` a039943_list) . iterate a003132
    a099645_list = map a099645 [1..]
    -- Reinhard Zumkeller, Aug 24 2011
  • Mathematica
    fu[x_] :=Apply[Plus, IntegerDigits[x]^2];hs=20; (* transient lengths are obtained by: *) a[n_] :=-1+Min[Flatten[Position[NestList[fu, n, Length[Union[NestList[fu, n, hs]]]] -Last[NestList[fu, n, Length[Union[NestList[fu, n, hs]]]]], 0]]]; Table[a[n], {n, 1, 256}]
  • PARI
    A099645(n)={ local( c=0, S=Set([1,4,16,37,58,89,145,42,20])); while( !setsearch(S,n), n=A003132(n); c++); c} \\ M. F. Hasler, May 24 2009
    

Extensions

Terms checked using the given PARI code. However, according to the domain of A003132 and the definition of A039943 (which both include 0), an initial a(0)=0 should be added here, too. - M. F. Hasler, May 24 2009
Previous Showing 21-30 of 118 results. Next