> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/f/fibonacci_word.md).

# Fibonacci word

```ruby
func entropy(s) {
    [0] + (s.chars.freq.values »/» s.len) -> reduce { |a,b|
        a - b*b.log2
    }
}
 
var n_max = 37
var words = ['1', '0']
 
{
    words.append(words[-1] + words[-2])
} * (n_max - words.len)
 
say ('%3s %10s %15s  %s' % <N Length Entropy Fibword>...)
 
for i in ^words {
    var word = words[i]
    say ('%3i %10i %15.12f  %s' % (i+1,
                                   word.len,
                                   entropy(word),
                                   word.len<30 ? word : '<too long>'))
}
```
