OFFSET
2,2
COMMENTS
a(n) = A056737(n) for nonsquare n. a(p) = p-1 for prime p.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 2..10000
MAPLE
with(numtheory):
a:= n-> min(seq((h-> `if`(h>0, h, NULL))(d-n/d), d=divisors(n))):
seq(a(n), n=2..100); # Alois P. Heinz, Nov 12 2014
PROG
(PARI) for(n=2, 100, v=divisors(n); r=sqrt(n); t=0; for(k=1, length(v), if(v[k]>=r, t=k; break)); if(v[t]^2==n, u=t, u=t-1); if(v[t]-v[u]<1, u=u-1; t=t+1); print1(v[t]-v[u]", "))
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Ralf Stephan, Apr 04 2003
STATUS
approved