Fibonacci Word | program for nth Fibonacci word ; Returns n - th Fibonacci word ; driver program
#include <bits/stdc++.h> NEW_LINE using namespace std ; string fibWord ( int n ) { string Sn_1 = "0" ; string Sn = "01" ; string tmp ; for ( int i = 2 ; i <= n ; i ++ ) { tmp = Sn ; Sn += Sn_1 ; Sn_1 = tmp ; } return Sn ; } int main ( ) { int n = 6 ; cout << fibWord ( n ) ; return 0 ; }