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

A244144 Alternating sum of digits of n^n.

Original entry on oeis.org

1, 4, -5, 3, -1, 5, 5, -5, 5, 1, -11, -10, 8, 4, 21, -38, 8, -2, 7, 1, 1, 0, 10, -5, 23, 26, 3, -7, 19, 23, -24, 23, 11, 56, 10, 36, 5, 37, 24, -32, 8, 15, -1, -33, -10, 20, 20, -35, 31, 23, -18, 24, -14, -34, 0, -1, 40, 16, 14, -21, 6, -27, -17, -5, -32, 11, 12, -41, 59, -23, -38, 52, -42, -29, -21, 12, 0, -1, -39, 1, -7, -19, -7, -25, -34
Offset: 1

Views

Author

Anthony Sand, Jun 21 2014

Keywords

Comments

The alternating sum of the digits of n^n is the sum obtained by alternately adding and subtracting the digits of n^n from left to right. For example, 4^4 = 256, therefore the alternating sum = 2 - 5 + 6 = 3. 7^7 = 823543, alternating sum = 8 - 2 + 3 - 5 + 4 - 3 = 5.

Examples

			If the function f(x) alternately adds and subtracts the digits of x from left to right, then:
a(1) = f(1^1) = f(1) = 1.
a(2) = f(2^2) = f(4) = 4.
a(3) = f(3^3) = f(27) = 2 - 7 = -5.
a(4) = f(4^4) = f(256) = 2 - 5 + 6 = 3.
a(9) = f(9^9) = f(387420489) = 3 - 8 + 7 - 4 + 2 - 0 + 4 - 8 + 9 = 5.
		

Crossrefs

Programs

  • Maple
    a:= n-> -(s->add(parse(s[i])*(-1)^i, i=1..length(s)))(""||(n^n)):
    seq(a(n), n=1..80);  # Alois P. Heinz, Jun 21 2014
  • Mathematica
    f[n_] := Block[ {d = IntegerDigits[ n], k = l = 1, s = 0}, l = Length[d]; While[ k <= l, s = s - (-1)^k*d[[k]]; k++ ]; Return[s]]; Table[ f[n^n], {n, 1, 100} ] (* Minor adaptation from program for A065796. *)

A065816 Numbers k such that the alternating sum of digits of k^2 is 0.

Original entry on oeis.org

11, 22, 33, 55, 66, 88, 99, 110, 121, 132, 165, 198, 209, 220, 231, 242, 264, 319, 330, 374, 385, 429, 451, 462, 484, 495, 506, 517, 528, 550, 561, 583, 605, 616, 649, 660, 671, 682, 715, 737, 748, 814, 836, 847, 880, 891, 902, 913, 924, 935, 957, 990
Offset: 1

Views

Author

Robert G. Wilson v, Dec 06 2001

Keywords

Crossrefs

Cf. A065796.

Programs

  • Mathematica
    f[n_] := Block[ {d = Reverse[ IntegerDigits[ n]], k = l = 1, s = 0}, l = Length[d]; While[ k <= l, s = s - (-1)^k*d[[k]]; k++ ]; Return[s]]; Select[ Range[10^3], f[ #^2] == 0 & ]
    Select[Range[1000],Total[Times@@@Partition[Riffle[IntegerDigits[#^2],{1,-1},{2,-1,2}],2]]==0&] (* Harvey P. Dale, Dec 19 2021 *)
  • PARI
    SumAD(x)= { local(a=1, s=0); while (x>9, s+=a*(x-10*(x\10)); x\=10; a=-a); return(s + a*x) } { n=0; for (m=1, 10^9, if (SumAD(m^2) == 0, write("b065816.txt", n++, " ", m); if (n==1000, return)) ) } \\ Harry J. Smith, Oct 31 2009
Showing 1-2 of 2 results.