Program to generate Baum-Sweet Sequence until a given binary number ( A Decimal number is given as input) using C++

In this program, a decimal number is taken as input and then converted to the binary equivalent using a user-defined function then the binary number is used to generate Baum-Sweet Sequence

In mathematics the **Baum–Sweet sequence** is an infinite automatic sequence of 0s and 1s defined by the rule:

*b*_{n}= 1 if the binary representation of*n*contains no block of consecutive 0s of odd length;*b*_{n}= 0 otherwise;

for *n* ≥ 0.

For example, *b8* = 0 because the binary representation of 8 is 1000, which contains one block of consecutive 0s of length 3; whereas *b9* = 1 because the binary representation of 9 is 1001, which contains a block of consecutive 0s of length 2 which is not odd.

here is the sequence for few terms starting from n=0 :

- 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1 ...

**Generation of** **Baum–Sweet sequence**

A user-defined function is defined to check given number has a block of consecutive 0s or not, if yes then is it odd or even length based on given condition 1 or 0 is returned as output for the corresponding number

Submitted by Sheshagiri Kulkarni (sheshagiri)

Download packets of source code on Coders Packet

## Comments