Sturmian word
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.
![Task](http://static.miraheze.org/rosettacodewiki/thumb/b/ba/Rcode-button-task-crushed.png/64px-Rcode-button-task-crushed.png)
You are encouraged to solve this task according to the task description, using any language you may know.
![](https://upload.wikimedia.org/wikipedia/commons/thumb/2/2d/Fibonacci_word_cutting_sequence.png/300px-Fibonacci_word_cutting_sequence.png)
The Sturmian word can be computed thus as an algorithm:
- If , then it is the inverse of the Sturmian word for . So we have reduced to the case of .
- Iterate over
- If is an integer, then the program terminates. Else, if , then the program outputs 0, else, it outputs 10.
The problem:
- Given a positive rational number , specified by two positive integers , output its entire Sturmian word.
- Given a quadratic real number , specified by three positive integers , where is not a perfect square, output the first letters of its Sturmian word when given a positive number .
Stretch goal: calculate the Sturmian word for other kinds of definable real numbers, such as cubic roots.