#include <stdio.h>

/*
This tool computes the sequence A230127 in the OEIS (and its natural generalization where |x| > s for some fixed positive integer s). s = 1 corresponds to the sequence A230127 and s = 2 corresponds to the sequence A229614.

Author: Nathaniel Johnston (nathaniel@njohnston.ca)
Version: 1.00
Last Updated: Oct. 10, 2013
*/

unsigned char dig[64];
unsigned int n,s;
unsigned long long int ct;

void extract_binary(unsigned long long int curI);
unsigned char check_no_square();

int main()
{
    long long int i;

    printf("This tool computes the sequence A230127 in the OEIS (and its natural generalization where |x| > s).\n\nPlease enter s (s >= 1): ");
    scanf("%d",&s);
    printf("\n");

    s = s+1;
    for(n=1; n<64; n++){
        ct = 0;
        for(i=pow(2,n)-1; i>=0; i--){
            extract_binary(i);
            ct += check_no_square();
        }

        printf("%llu, ", ct);
    }
    return 0;
}

void extract_binary(unsigned long long int curI)
{
    unsigned short int j;

    for(j=0; j<n; j++){
        dig[j] = curI % 2;
        curI = curI / 2;
    }
}

unsigned char check_no_square()
{
    unsigned int k,p,m,is_dup;
    for(k=s; k<=n/2; k++){
        for(p=0; p<=n-2*k; p++){
            is_dup = 1;
            for(m=0; m<k; m++){
                if(dig[p+m] != dig[p+m+k]){
                    is_dup = 0;
                    break;
                }
            }
            if(is_dup){
                return 0;
            }
        }
    }
    return 1;
}