%I #79 Dec 21 2024 11:08:40
%S 0,1,2,2,4,3,6,4,6,5,10,6,12,7,10,8,16,9,18,10,14,11,22,12,20,13,18,
%T 14,28,15,30,16,22,17,28,18,36,19,26,20,40,21,42,22,30,23,46,24,42,25,
%U 34,26,52,27,44,28,38,29,58,30,60,31,42,32,52,33,66,34,46,35,70,36,72,37
%N Largest difference between consecutive divisors of n (ordered by size).
%C Is a(n) the least m > 0 such that n - m divides n! + m? - _Clark Kimberling_, Jul 28 2012
%C Is a(n) the least m > 0 such that L(n-m) divides L(n+m), where L = A000032 (Lucas numbers)? - _Clark Kimberling_, Jul 30 2012
%C Records give A006093. - _Omar E. Pol_, Oct 26 2013
%C Divide n by its smallest prime factor p, then multiply with (p-1), with a(1) = 0 by convention. Compare also to A366387. - _Antti Karttunen_, Oct 23 2023
%C a(n) is also the smallest LCM of positive integers x and y where x + y = n. - _Felix Huber_, Aug 28 2024
%H Reinhard Zumkeller, <a href="/A060681/b060681.txt">Table of n, a(n) for n = 1..10000</a>
%H Antal Balog, Paul Erdős, and Gérald Tenenbaum,, <a href="http://dx.doi.org/10.1007/978-1-4612-3464-7_6">On Arithmetic Functions Involving Consecutive Divisors</a>, In: Analytical Number Theory, pp. 77-90, Birkhäuser, Basel, 1990.
%F a(n) = n - n/A020639(n).
%F a(n) = n - A032742(n). - _Omar E. Pol_, Aug 31 2011
%F a(2n) = n, a(3*(2n+1)) = 2*(2n+1) = 4n + 2. - _Antti Karttunen_, Oct 23 2023
%F Sum_{k=1..n} a(k) ~ (1/2 - c) * n^2, where c is defined in the corresponding formula in A032742. - _Amiram Eldar_, Dec 21 2024
%e For n = 35, divisors are {1, 5, 7, 35}; differences are {4, 2, 28}; a(35) = largest difference = 28 = 35 - 35/5.
%p read("transforms") :
%p A060681 := proc(n)
%p if n = 1 then
%p 0 ;
%p else
%p sort(convert(numtheory[divisors](n),list)) ;
%p DIFF(%) ;
%p max(op(%)) ;
%p end if;
%p end proc:
%p seq(A060681(n),n=1..60) ; # _R. J. Mathar_, May 23 2018
%p # second Maple program:
%p A060681:=n->if(n=1,0,min(map(x->ilcm(x,n-x),[$1..1/2*n]))); seq(A060681(n),n=1..74); # _Felix Huber_, Aug 28 2024
%t a[n_ ] := n - n/FactorInteger[n][[1, 1]]
%t Array[Max[Differences[Divisors[#]]] &, 80, 2] (* _Harvey P. Dale_, Oct 26 2013 *)
%o (Haskell)
%o a060681 n = div n p * (p - 1) where p = a020639 n
%o -- _Reinhard Zumkeller_, Apr 06 2015
%o (PARI) diff(v)=vector(#v-1,i,v[i+1]-v[i])
%o a(n)=vecmax(diff(divisors(n))) \\ _Charles R Greathouse IV_, Sep 02 2015
%o (PARI) a(n) = if (n==1, 0, n - n/factor(n)[1,1]); \\ _Michel Marcus_, Oct 24 2015
%o (PARI) first(n) = n = max(n, 1); my(res = vector(n)); res[1] = 0; forprime(p = 2, n, for(i = 1, n \ p, if(res[p * i] == 0, res[p * i] = i*(p-1)))); res \\ _David A. Corneth_, Jan 08 2019
%o (Python)
%o from sympy import primefactors
%o def A060681(n): return n-n//min(primefactors(n),default=1) # _Chai Wah Wu_, Jun 21 2023
%Y Cf. A013661, A020639, A060680, A060682, A060683, A060685, A064097 (number of iterations needed to reach 1).
%Y Cf. also A171462, A366387.
%K nonn,easy
%O 1,3
%A _Labos Elemer_, Apr 19 2001
%E Edited by _Dean Hickerson_, Jan 22 2002
%E a(1)=0 added by _N. J. A. Sloane_, Oct 01 2015 at the suggestion of _Antti Karttunen_