OFFSET
1,4
COMMENTS
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.
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..20000
EXAMPLE
a(6) = 5 because 6-3+2=5
a(7) = 1 because 7-7+1=1
a(9) = 9 because 9-3+3=9.
MATHEMATICA
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}]
PROG
(PARI) A101322(n) = fordiv(n, d, if((d^2) >= n, return(n+(n/d)-d))); \\ Antti Karttunen, Jan 18 2025
CROSSREFS
KEYWORD
nonn
AUTHOR
Joseph Biberstine (jrbibers(AT)indiana.edu), Dec 24 2004
EXTENSIONS
Name corrected to match the given formula and the data, more terms added by Antti Karttunen, Jan 18 2025
STATUS
approved