Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kynea numbers #31

Merged
merged 2 commits into from
Jul 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions oeis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from .factorial import factorial
from .fibonacci import fibonacci
from .jacobsthal import jacobsthal
from .kynea import kynea
from .lazy_caterer import lazy_caterer
from .leonardo import leonardo
from .loeschian import loeschian
Expand Down Expand Up @@ -95,6 +96,7 @@
"hexagonal",
"hexagonal_pyramidal",
"jacobsthal",
"kynea",
"lazy_caterer",
"leonardo",
"loeschian",
Expand Down
12 changes: 12 additions & 0 deletions oeis/kynea.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# coding=utf-8
from itertools import count
from typing import Iterable

from oeis.registry import registry


@registry.register("A093069")
def kynea() -> Iterable[int]:
"""Kynea numbers."""
for n in count(start=1):
yield pow(pow(2, n) + 1, 2) - 2
45 changes: 37 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions tests/test_oeis.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
hexagonal,
hexagonal_pyramidal,
jacobsthal,
kynea,
lazy_caterer,
leonardo,
loeschian,
Expand Down Expand Up @@ -232,6 +233,12 @@ def test_jacobsthal() -> None:
assert actual == expected


def test_kynea() -> None:
expected: List[int] = [7, 23, 79, 287, 1087, 4223, 16639, 66047, 263167, 1050623]
actual: List[int] = list(islice(kynea(), 10))
assert actual == expected


def test_lazy_caterer() -> None:
expected: List[int] = [1, 2, 4, 7, 11, 16, 22, 29, 37, 46]
actual: List[int] = list(islice(lazy_caterer(), 10))
Expand Down