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.

A238986 Ground Pyramidalized Numbers: Write the decimal digits of 'n' (a nonnegative integer) and take successive absolute differences ("pyramidalization"), then sum all digits of each level of the pyramid. If total is greater than 9, repeat the process until result is between 0 and 9, which is 'a(n)' (0 <= a(n) <= 9).

Original entry on oeis.org

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

Views

Author

Filipi R. de Oliveira, Mar 07 2014

Keywords

Comments

A given nonnegative integer 'n' is decomposed to its digits and the absolute differences between the digits are taken, then the differences between differences between digits (and so on, until the top of the "gap-pyramid" is reached - we could call this process "pyramidalization"). If the sum 's(n)' of the resulting digits is 0 <= s(n) <= 9, it's 'a(n)'; if greater than 9, the same process is applied to the result, and to the subsequent result if necessary, and so on, until the result is smaller than 10.

Examples

			If n=364, a(364)=4, for...
.
____1
__3_:_2__ -->b'(364)=3+6+4+|3-6|+|6-4|+||3-6|-|6-4||=3+6+4+3+2+1=19>9
3_:_6_:_4
.
__8
1_:_9  --> b''(364)=1+9|1-9|=1+9+8=18>9
.
__7
1_:_8 --> b'''(364)=1+8+|1-8|=1+8+7=16>9
.
__5
1_:_6 --> b''''(364)=1+6+|1-6|=1+6+5=12>9
.
__1
1_:_2 --> b'''''(364)=1+2+|1-2|=1+2+1=4=a(364)
		

Crossrefs

Cf. A227876. The pyramidalization process is applied and reapplied to each term until the result reaches its "ground limit".
Cf. A007318. The pyramidalization process relates to Pascal's Triangle because it is done in the opposite direction (towards the top instead of the base), using the contrary operation (absolute difference instead of sum of the prior terms).

Programs

  • Mathematica
    a[n_] := If[n < 10, n, Block[{d = IntegerDigits@ n, s}, s = Total@ d; While[Length@ d > 1, d = Abs@ Differences@ d; s += Total@d]; If[s < 10, s, a@s]]]; a /@ Range[0, 99] (* Giovanni Resta, Mar 16 2014 *)

Formula

a(n)=n, if 0<=n<=9;
b'(n)=n-9*floor(n/10)+|-n+11*floor(n/10)|, if 10<=n<=99;
b'(n)=a(n), if 0<=b'(n)<=9;
else, b''(n)=b'(n)-9*floor(b'(n)/10)+|-b'(n)+11*floor(b'(n)/10)|;
b''(n)=a(n), if 0<=b''(n)<=9;
else, b'''(n)=...
c'(n)=n-9*floor(n/10)-9*floor(n/100)+|-floor(n/10)+11*floor(n/100)|+|-n+11*floor(n/10)-10*floor(n/100)|+||-floor(n/10)+11*floor(n/100)|-|-n+11*floor(n/10)-10*floor(n/100)||, if 100<=n<=999.
c'(n)=a(n), if 0<=c'(n)<=9;
else, if 10<=c'(n)<=99, c''(n)=c'(n)-9*floor(c'(n)/10)+|-c'(n)+11*floor(c'(n)/10)|;
c''(n)=a(n), if 0<=c''(n)<=9
else, ...