#Mathematica, 50 48 45 40 38 35 31 29 bytes
Mathematica, 50 48 45 40 38 35 31 29 bytes
Mathematica generally sucks when it comes to code golf, but sometimes there's a built-in that makes things look really nice.
1<#<4^IntegerExponent[#-1,2]& A test:
Reap[Do[If[f[i],Sow[i]],{i,1,1000}]][[2,1]] {3, 5, 9, 13, 17, 25, 33, 41, 49, 57, 65, 81, 97, 113, 129, 145, 161, 177, 193, 209, 225, 241, 257, 289, 321, 353, 385, 417, 449, 481, 513, 545, 577, 609, 641, 673, 705, 737, 769, 801, 833, 865, 897, 929, 961, 993} Edit: Actually, if I steal Dennis's bitwise AND idea, I can get it down to 23 22 20 bytes.
#Mathematica, 23 22 20 bytes (thanks A Simmons)
Mathematica, 23 22 20 bytes (thanks A Simmons)
BitAnd[#-1,1-#]^2>#&