j15Q[n_]:=Module[{idn8=IntegerDigits[n, 8]}, SequenceCount[idn8, {1, 5}]>0 || SequenceCount[idn8, {5, 1}]>0]; Transpose[ SequencePosition[Table[If[ j15Q[k], 1, 0], {k, 1500}], {0, 1}]][[2]] (* The program uses the SequenceCount and SequencePosition functions from Mathematica version 10 *) (* Harvey P. Dale, Aug 09 2015 *)