login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A138224 a(n) is the divisor of n that is nearest to tau(n), the number of divisors of n. In case of a tie, take the smaller of those two divisors. 4

%I #21 Jun 18 2021 11:34:57

%S 1,2,1,2,1,3,1,4,3,5,1,6,1,2,3,4,1,6,1,5,3,2,1,8,1,2,3,7,1,6,1,4,3,2,

%T 5,9,1,2,3,8,1,7,1,4,5,2,1,8,1,5,3,4,1,9,5,8,3,2,1,12,1,2,7,8,5,6,1,4,

%U 3,7,1,12,1,2,5,4,1,6,1,10,3,2,1,12,5,2,3,8,1,10,1,4,3,2,5,12,1,7,3,10,1,6

%N a(n) is the divisor of n that is nearest to tau(n), the number of divisors of n. In case of a tie, take the smaller of those two divisors.

%H Antti Karttunen, <a href="/A138224/b138224.txt">Table of n, a(n) for n = 1..16384</a>

%e There are four divisors of 15: (1,3,5,15). There are two divisors, 3 and 5, that are nearest 4. Since there is a tie (4 is equidistant from 3 and 5), we take the smaller divisor, 3, so a(15) = 3.

%p A138224 := proc(n) if n = 1 then RETURN(1); fi; t := numtheory[tau](n) ; dvs := sort(convert(numtheory[divisors](n),list)) ; a := op(1,dvs) ; for i from 2 to nops(dvs) do if abs(op(i,dvs) - t) < abs(a-t) then a := op(i,dvs) ; fi; od: a ; end: seq(A138224(n),n=1..120) ; # _R. J. Mathar_, Jul 20 2009

%t nd[n_]:=Module[{div=Divisors[n]},Nearest[div,Length[div]][[1]]]; Array[ nd,110] (* _Harvey P. Dale_, Jun 17 2018 *)

%o (PARI) A138224(n) = { my(pd=0,u=numdiv(n)); fordiv(n,d,if(d>u,return(if((d-u)<(u-pd),d,pd))); pd=d); (pd); }; \\ _Antti Karttunen_, Apr 01 2021

%Y Cf. A000005, A138221, A138222, A138223.

%K nonn

%O 1,2

%A _Leroy Quet_, Mar 06 2008

%E Extended beyond a(15) by _R. J. Mathar_, Jul 20 2009

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 11:06 EDT 2024. Contains 371967 sequences. (Running on oeis4.)