login
Numbers that are periodic in base 4, written in decimal, where the base-4 expansion contains at least two periods.
3

%I #38 Nov 19 2018 20:59:31

%S 5,10,15,17,21,34,42,51,63,65,68,85,102,119,130,136,153,170,187,195,

%T 204,221,238,255,257,260,273,325,341,390,455,514,520,546,585,650,682,

%U 715,771,780,819,845,910,975,1023,1025,1028,1040,1092,1105,1170,1235,1285

%N Numbers that are periodic in base 4, written in decimal, where the base-4 expansion contains at least two periods.

%e The base-4 representation of 17 is 101, which is periodic when considering leading zeros, i.e., 0101, so 17 is a term of the sequence.

%e The base-4 representation of 170 is 2222, which is periodic, so 170 is a term of the sequence.

%e The base-4 representation of 1495 is 113113, which is periodic, so 1495 is a term of the sequence.

%o (PARI) subvec(vec, pos, len) = my(w=[]); for(k=pos, pos+len-1, if(k > #vec, return(0), w=concat(w, vec[k]))); w

%o is_perio(vec) = my(d=divisors(#vec), v=[], w=[]); for(x=2, #d-1, v=subvec(vec, 1, d[x]); forstep(y=1, #vec, d[x], w=subvec(vec, y, d[x]); if(w!=v, break, if(y+d[x] >= #vec, return(1))))); 0

%o is(n) = my(d=digits(n, 4), z=[]); if(#d < 2, return(0)); if(vecmin(d)==vecmax(d), return(1)); while(#z <= #d, if(is_perio(concat(z, d)), return(1)); z=concat(z, [0])); 0

%o (PARI) is(n, b=4) = for (w=1, oo, my (d=digits(n, b^w)); if (#d<=1, return (0), #Set(d)==1, return (1))) \\ _Rémy Sigrist_, Nov 16 2018

%Y Cf. A007090, A242139.

%K nonn,base

%O 1,1

%A _Felix Fröhlich_, Nov 11 2018