n=1000000; non2={}; max=0; maxList={}; For[i=2, i<=n, i++, If[SquareFreeQ[i], non2=non2~Join~{i}]] nn=Length[non2]; For[i=1, i<=nn, i++, t=non2[[i]]; y=t Sqrt[t]; x=y-Round[y]; x=Abs[1/x]; If[x>max, max=x; maxList=maxList~Join~{{t, Round[y]}}]] MatrixForm[maxList]