A027387 Write digits for n, count endpoints (version 2).
0, 2, 2, 2, 4, 2, 1, 2, 0, 1, 2, 4, 4, 4, 6, 4, 3, 4, 2, 3, 2, 4, 4, 4, 6, 4, 3, 4, 2, 3, 2, 4, 4, 4, 6, 4, 3, 4, 2, 3, 4, 6, 6, 6, 8, 6, 5, 6, 4, 5, 2, 4, 4, 4, 6, 4, 3, 4, 2, 3, 1, 3, 3, 3, 5, 3, 2, 3, 1, 2, 2, 4, 4, 4, 6, 4, 3, 4, 2, 3, 0
Offset: 0
Examples
The digit 1 has two endpoints, and the digit 8 has no endpoints, so a(18) = 2. - _Michael B. Porter_, Oct 28 2017
Links
- Paolo Xausa, Table of n, a(n) for n = 0..10000
Programs
-
Mathematica
A027387[n_] := Total[Map[{0, 2, 2, 2, 4, 2, 1, 2, 0, 1}[[#+1]] &, IntegerDigits[n]]]; Array[A027387, 100, 0] (* Paolo Xausa, Jul 16 2025 *)
-
PARI
a(n)=vecsum(apply(d->[0, 2, 2, 2, 4, 2, 1, 2, 0, 1][d+1], digits(n))); \\ based on program for A027386 by Andrew Howroyd, Michael B. Porter, Oct 26 2017
Formula
a(10*n + d) = a(n) + e where e is the number of endpoints of single digit d. - David A. Corneth, Oct 28 2017
Extensions
a(6) corrected by Michael B. Porter, Oct 28 2017 (per Andrew Howroyd)
a(27) to a(80) by Michael B. Porter, Oct 28 2017
Comments