Skip to content

Commit

Permalink
Perrin numbers (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
VascoSch92 committed Jan 6, 2024
2 parents c3ee435 + 79544f2 commit c7e4602
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The version is represented by three digits: a.b.c.
ENHANCEMENT:
- sequentium.github.workflows.release.yml: workflow for automatic upload on pypi
- sequentium.sequence.sequences.integer.periodic_generalised.py: added class for representing constant sequences
- sequentium.sequence.sequences.integer.recursive.py: added sequence A001608

---
## [0.0.1] - 2024-01-02
Expand Down
1 change: 1 addition & 0 deletions sequence/SEQUENCES_LIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ List of implemented integer sequences.
| A001228 | Orders of sporadic simple groups | `A001228` | https://oeis.org/A001228 |
| A001591 | The Pentanacci numbers | `A001591`, `PentanacciNumbers` | https://oeis.org/A001591 |
| A001592 | The Hexanacci numbers | `A001592`, `HexanacciNumbers` | https://oeis.org/A001592 |
| A001608 | Perrin numbers | `A001608`, `PerrinNumbers` | https://oeis.org/A002203 |
| A002203 | Companion Pell numbers | `A002203`, `CompanionPellNumbers`, `PellLucasNumbers` | https://oeis.org/A002203 |
| A002808 | The composite numbers | `A002808`, `CompositeNumbers`, `PositiveCompositeNumbers` | https://oeis.org/A002808 |
| A003173 | The Heegner numbers | `A003173`, `HeegnerNumbers` | https://oeis.org/A003173 |
Expand Down
14 changes: 14 additions & 0 deletions sequence/sequences/integer/recursive.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ def __init__(self) -> None:
HexanacciNumbers = A001591


class A001608(AlmostMonotonicIncreasingMixin, Recursive):
"""Perrin numbers (https://oeis.org/A001608)."""
sequence_name = 'Perrin numbers'
offset: ClassVar[List[int]] = [3, 0, 2, 3, 2, 5]

def __init__(self) -> None:
super().__init__(start_terms=(3, 0, 2))

def formula(self, terms: Tuple[Any, ...]) -> Tuple[Any, ...]:
return terms[1], terms[2], terms[1] + terms[0]


PerrinNumbers = A001608

class A002203(LucasSequenceV):
"""Companion Pell numbers (https://oeis.org/A002203)."""
sequence_name = 'Companion Pell numbers'
Expand Down
10 changes: 10 additions & 0 deletions tests/tests_integer_sequences/test_recursive.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ class TestA001592(SequenceTestSuite):
]


class TestA001608(SequenceTestSuite):
sequence = A001608()
sequence_name = 'Perrin numbers'
ground_truth = [
3, 0, 2, 3, 2, 5, 5, 7, 10, 12, 17, 22, 29, 39, 51, 68, 90, 119, 158, 209, 277, 367, 486, 644, 853, 1130, 1497,
1983, 2627, 3480, 4610, 6107, 8090, 10717, 14197, 18807, 24914, 33004, 43721, 57918, 76725, 101639, 134643,
178364, 236282, 313007,
]


class TestA002203(SequenceTestSuite):
sequence = A002203()
sequence_name = 'Companion Pell numbers'
Expand Down

0 comments on commit c7e4602

Please sign in to comment.