%I #18 Jan 18 2025 10:06:58
%S 1,1,1,4,1,5,1,6,9,7,1,11,1,9,13,16,1,15,1,19,17,13,1,22,25,15,21,25,
%T 1,29,1,28,25,19,33,36,1,21,29,37,1,41,1,37,41,25,1,46,49,45,37,43,1,
%U 51,49,55,41,31,1,56,1,33,61,64,57,61,1,55,49,67,1,71,1,39,65,61,73,71,1,78,81,43,1,79,73,45,61,85,1,89,85
%N a(n) = n - (least divisor of n >= the square root of n) + (greatest divisor of n <= the square root of n).
%C a(n)/n represents, in some sense, how 'square' a positive integer n is. a(n)=1 iff n is a prime number (or 1). a(n)=n iff n is a square number. For nonsquare n, the first (note: not zeroth) partial quotient of the continued fraction of a(n)/n is n iff n is prime, else 1.
%H Antti Karttunen, <a href="/A101322/b101322.txt">Table of n, a(n) for n = 1..20000</a>
%F a(n) = n + A033676(n) - A033677(n).
%e a(6) = 5 because 6-3+2=5
%e a(7) = 1 because 7-7+1=1
%e a(9) = 9 because 9-3+3=9.
%t Table[n - If[EvenQ[DivisorSigma[0, n]], Divisors[n][[DivisorSigma[0, n]/2 + 1]], Sqrt[n]] + If[EvenQ[DivisorSigma[0, n]], Divisors[n][[DivisorSigma[0, n]/2]], Sqrt[n]], {n, 1, 128}]
%o (PARI) A101322(n) = fordiv(n,d,if((d^2) >= n,return(n+(n/d)-d))); \\ _Antti Karttunen_, Jan 18 2025
%Y Cf. A008578 (positions of 1's), A000290 (fixed points), A033676, A033677.
%K nonn
%O 1,4
%A Joseph Biberstine (jrbibers(AT)indiana.edu), Dec 24 2004
%E Name corrected to match the given formula and the data, more terms added by _Antti Karttunen_, Jan 18 2025