and 1 contributors

# NAME

Math::NumSeq::SevenSegments -- count of segments to display by 7-segment LED

# SYNOPSIS

`````` use Math::NumSeq::SevenSegments;
my \$seq = Math::NumSeq::SevenSegments->new;
my (\$i, \$value) = \$seq->next;``````

# DESCRIPTION

This sequence is how many segments are lit to display i in 7-segment LEDs

``````    i     = 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 ...
value = 6, 2, 5, 5, 4, 5, 6, 3, 7, 5, 8, 4, 7, 7, 6, 7, 8 ...
(A277116)``````

The segments for each digit are

``````     ---                 ---       ---
|   |         |         |         |     |   |
---       ---       ---
|   |         |     |             |         |
---                 ---       ---

---       ---       ---       ---       ---
|         |             |     |   |     |   |
---       ---                 ---       ---
|     |   |         |     |   |         |
---       ---                 ---``````

i=0 is considered to require one 0 digit, as is usual for a human display. (Although many mathematical things are much better consistently omitting all high 0 digits so that 0 is no digits.)

Option `six => \$integer` is how many segments for digit 6. Occasionally it may be shown without the top, so 5 segments (instead of 6). This tends to look like a "b", and certainly would not be used when wanting an actual b too (for hexadecimal or text).

``````    |
---         six => 5   segments, (no top)
|   |
---``````

Option `seven => \$integer` is how many segments for digit 7. Sometimes 7 has a top-left "serif",

``````     ---
|   |        seven => 4   segments (with top left)

|``````

Option `nine => \$integer` is how many segments for digit 9. Often 9 has a bottom segment.

``````     ---
|   |        nine  => 6   segments (with bottom segment)
---
|
---``````

It might have been more consistent if the default had been 6 and 9 both 6 segments, but the options allow any combination.

The total segments to display i is similar to Math::NumSeq::DigitSum, but with digits mapped through a table of segment counts 0->6, 1->2, 2->5, etc.

# FUNCTIONS

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.

`\$seq = Math::NumSeq::SevenSegments->new ()`
`\$seq = Math::NumSeq::SevenSegments->new (key => value, ...)`

Create and return a new sequence object. The optional key/value parameters are the number of segments lit for digits 6, 7, or 9,

``````    six   => \$integer, default 6
seven => \$integer, default 3
nine  => \$integer, default``````

## Random Access

`\$value = \$seq->ith(\$i)`

Return the number of segments to display `\$i` in 7-segment LEDs.

`\$i = \$seq->i_start ()`

Return 0, the first term in the sequence being at i=0.

# OEIS

Entries in Sloane's Online Encyclopedia of Integer Sequences related to this sequence include

``````    A277116      default
A074458      seven => 4              (but it just 0..9)
A010371      seven => 4, nine => 6
A006942                  nine => 6
A063720      six => 5``````

Tk::SevenSegmentDisplay