#C, 82 bytes, safe
C, 82 bytes, safe
####=############
main(i){scanf("%d",##);
for(i=1;i++/4<#;)##=2;
printf("%d",##);}
Works with gcc, and it is a full program, which reads its input from stdin and prints its output to stdout. Here the sequence is A004526, floor(n/2).
a(0) = 0 a(1) = 0 a(2) = 1
a(3) = 1 a(4) = 2 a(5) = 2
a(6) = 3 a(7) = 3 a(8) = 4
Solution:
a;*b=(char*)&a+1;
main(i){scanf("%d",&a);
for(i=1;i++/4<2;)a*=2;
printf("%d",*b);}
This works only on little endian machines, and only if the size of char
is 1 byte.
And only if the byte higher than the highest order byte of a
has value 0. I think this is true for gcc since by default uninitialized global variables go into the bss segment, and initialized global variables go into the data segment (see https://stackoverflow.com/questions/8721475/if-a-global-variable-is-initialized-to-0-will-it-go-to-bss).
So only a
goes into bss (the only other global variable b
is initialized and thus goes into the data segment). If a
is not at the end of bss, then the byte higher than the highest order byte of a
is also in bss and thus has value 0.