OFFSET
1,1
LINKS
Project Euler, Problem 234: Semidivisible numbers, Feb 28 2009.
FORMULA
EXAMPLE
For k=1,2,3, precprime(sqrt(k)) is undefined, so these are not considered here.
a(1) = 8 is divisible by 2=precprime(sqrt(8)) but not by 3=nextprime(sqrt(8)).
a(2) = 10 is divisible by 5=nextprime(sqrt(10)) but not by 3=precprime(sqrt(8)).
k=4,6,9,... are excluded since divisible by both precprime(sqrt(k)) and nextprime(sqrt(k)). (Note that precprime=A007917 and nextprime=A007918 are defined using weak inequalities.)
k=5,7,11,13,14,... are excluded since not divisible by precprime(sqrt(k)) nor by nextprime(sqrt(k)).
MATHEMATICA
ndQ[n_]:=Module[{s=Sqrt[n]}, Total[Boole[{Divisible[n, NextPrime[ s]], Divisible[ n, NextPrime[ s, -1]]}]]==1]; Select[Range[5, 500], ndQ] (* Harvey P. Dale, Mar 19 2019 *)
PROG
(PARI) for( n=4, 999, !(n % nextprime(sqrtint(n-1)+1)) != !(n % precprime(sqrtint(n))) & print1(n", ")) /* sqrtint(n-1)+1 avoids rounding errors but can be replaced by sqrt(n) for small n */
CROSSREFS
KEYWORD
nonn
AUTHOR
M. F. Hasler, Mar 10 2009
STATUS
approved
