login
Greatest squarefree number <= n.
11

%I #24 May 25 2023 13:18:48

%S 1,2,3,3,5,6,7,7,7,10,11,11,13,14,15,15,17,17,19,19,21,22,23,23,23,26,

%T 26,26,29,30,31,31,33,34,35,35,37,38,39,39,41,42,43,43,43,46,47,47,47,

%U 47,51,51,53,53,55,55,57,58,59,59,61,62,62,62,65,66,67,67,69,70,71,71

%N Greatest squarefree number <= n.

%C a(n) = Max( core(k) : k=1,2,3,...,n ) where core(x) is the squarefree part of x (the smallest integer such that x*core(x) is a square).

%H R. Zumkeller, <a href="/A070321/b070321.txt">Table of n, a(n) for n = 1..10000</a>

%p A070321 := proc(n)

%p local a;

%p for a from n by -1 do

%p if issqrfree(a) then

%p return a;

%p end if;

%p end do:

%p end proc:

%p seq(A070321(n),n=1..100) ; # _R. J. Mathar_, May 25 2023

%t a[n_] :=For[ k = n, True, k--, If[ SquareFreeQ[k], Return[k]]]; Table[a[n], {n, 1, 100}] (* _Jean-François Alcover_, Mar 27 2013 *)

%t gsfn[n_]:=Module[{k=n},While[!SquareFreeQ[k],k--];k]; Array[gsfn,80] (* _Harvey P. Dale_, Mar 27 2013 *)

%o (PARI) a(n) = while (! issquarefree(n), n--); n; \\ _Michel Marcus_, Mar 18 2017

%Y Cf. A005117, A007947, A067535, A076260.

%Y Cf. A081217, A081218, A081210.

%K easy,nonn

%O 1,2

%A _Benoit Cloitre_, May 11 2002

%E New description from _Reinhard Zumkeller_, Oct 03 2002