Baum-Sweet Sequence

Published by Mubashir Hassan in

Create a function that takes a number n and returns all the terms of the Baum-Sweet sequence, from 0 to n (included).

The Baum-Sweet sequence is the sequence of numbers bi such that bi = 1 if the binary representation of i contains no block of consecutive 0 of odd length, and bi = 0 otherwise.

Examples

baumSweet(0) ➞ "0"

baumSweet(1) ➞ "01"

baumSweet(10) ➞ "01011001010"

Notes

For all cases, n >= 0.

Watch a quick demo on how Edabit works.