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

Add sequence A000201 (lower Wythoff sequence). #381

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions oeis.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,10 @@ def A070939(i: int = 0) -> int:
"""Length of binary representation of n."""
return len(f"{i:b}")

@oeis.from_function()
def A000201(n: int) -> int:
"""Lower Wythoff sequence: a(n) = floor(n * phi), where phi = (1 + sqrt(5))/2 (golden ratio)"""
return (math.floor(n * (1 + math.sqrt(5))/2.0))

def main() -> None: # pylint: disable=too-many-branches
"""Command line entry point."""
Expand Down
13 changes: 13 additions & 0 deletions tests/test_A000201.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from oeis import A000201


def test_sequence():
from_oeis_org = [
int(i)
for i in """1, 3, 4, 6, 8, 9, 11, 12, 14, 16, 17, 19, 21, 22, 24, 25,
27, 29, 30, 32, 33, 35, 37, 38, 40, 42, 43, 45, 46, 48, 50, 51, 53, 55,
56, 58, 59, 61, 63, 64, 66, 67, 69, 71, 72, 74, 76, 77, 79, 80, 82, 84,
85, 87, 88, 90, 92, 93, 95, 97, 98, 100, 101, 103, 105, 106, 108, 110
""".split(", ")
]
assert A000201[1 : len(from_oeis_org) + 1] == from_oeis_org