From d9d608bc32ee31c73c139e1b68e4eb6315205e8d Mon Sep 17 00:00:00 2001 From: Tim Jones Date: Wed, 8 Dec 2021 15:01:01 -0600 Subject: [PATCH] Add sequence A000201 (lower Wythoff sequence). --- oeis.py | 4 ++++ tests/test_A000201.py | 13 +++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 tests/test_A000201.py diff --git a/oeis.py b/oeis.py index d9b949e..5b321e8 100644 --- a/oeis.py +++ b/oeis.py @@ -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.""" diff --git a/tests/test_A000201.py b/tests/test_A000201.py new file mode 100644 index 0000000..b63c25f --- /dev/null +++ b/tests/test_A000201.py @@ -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