Skip to content

Fibonacci is so last year, let's go with Lucas numbers. #116

@Pomax

Description

@Pomax

Made by hand, rather than using wtfjs, but I'm sure it's easy to redo:

function lucas(n) { for(_=++[+[]][+[]],__=++[_][+[]]<<++[_][+[]]<<++[_][+[]]<<_;__>+[];_=++[+[]][+[]]+(++[+[]][+[]]/_),__--);for(__=_;-++[+[]][+[]]+--n;_*=__);return(++[+[]][+[]]/++[++[+[]][+[]]][+[]]+_)|+[]; }

Computes the golden ratio φ by evaluating the continued fraction for the golden ratio over 64 iterations, then computes the Lucas number lucas(n) directly as round(φ^(n-1)).

(more detailed composition explained over at https://pomax.github.io/#gh-weblog-1418775170598)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions