Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Farey Sequence next term algorithm #1552

Open
@jxu

Description

@jxu

Article:The Stern-Brocot Tree and Farey Sequences

Problem:

Surprisingly the page is missing a nice way of computing the next term in F_n without any recursion.

https://en.wikipedia.org/wiki/Farey_sequence#Next_term

Given two consecutive entries a/b and c/d, the next term p/q is given by

p = ((n + b) // d) * c - aq = ((n + b) // d) * d - b

Start with a/b = 0/1 and c/d = 1/n.

I don't have a good source of this info other than wikipedia (who doesn't cite anything) but it's also here as Properties of Farey Sequences 5.https://dummit.cos.northeastern.edu/teaching_sp21_4527/4527_lecture_03_farey_sequences_v2.pdf

Also I should mention the number of terms at the end is 1 + Phi(n), where Phi is the totient summatory function, Phi(x) ~ (3 / pi^2) x^2 + O(x ln x).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp