login
Distance to closest prime in sequence of composites.
0

%I #6 Aug 31 2015 12:42:10

%S 1,1,1,2,1,1,1,2,1,1,1,2,1,1,2,3,2,1,1,1,2,3,2,1,1,2,1,1,1,2,1,1,2,3,

%T 2,1,1,2,3,2,1,1,1,2,3,2,1,1,2,1,1,1,2,3,2,1,1,2,1,1,2,3,2,1,1,2,3,4,

%U 3,2,1,1,2,1,1,1,2,1,1,1,2,1,1,2,3,4,5,6,7,6,5,4,3,2,1,1,2,1,1,2,3,2,1,1,1

%N Distance to closest prime in sequence of composites.

%F Beginning at 2, list consecutive numbers. Measure distance of each composite to nearest prime.

%e Fourth composite number is 9; distance to nearest prime, 7 or 11, is 2, so a(4) = 2.

%t Min[NextPrime[#]-#,#-NextPrime[#,-1]]&/@Select[Range[140],CompositeQ] (* _Harvey P. Dale_, Aug 31 2015 *)

%K easy,nonn

%O 1,4

%A _Enoch Haga_, Jan 16 2000