Sturmian word

From Rosetta Code
Revision as of 22:37, 31 January 2024 by imported>CosmiaNebula (Sturmian word)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Task
Sturmian word
You are encouraged to solve this task according to the task description, using any language you may know.

A Sturmian word is a binary sequence, finite or infinite, that makes up the cutting sequence for a positive real number x, as shown in the picture.

Example Sturmian word when x = 0.618..., the golden ratio.

The Sturmian word can be computed thus as an algorithm:

  • If x > 1, then it is the inverse of the Sturmian word for (1/x). So we have reduced to the case of 0 < x < 1.
  • Iterate over
  • If is an integer, then the program terminates. Else, if , then the program outputs 0, else, it outputs 10.