%I #22 Nov 07 2024 02:27:45
%S 1,1,1,1,1,1,1,1,1,10,11,12,13,14,15,16,17,18,19,10,21,11,23,12,25,13,
%T 27,14,29,10,31,16,11,17,35,12,37,19,13,10,41,14,43,11,15,23,47,12,49,
%U 10,17,13,53,18,11,14,19,29,59,10,61,31,21,16,13,11,67
%N a(n) is the least divisor of n with as many decimal digits as n.
%H Rémy Sigrist, <a href="/A377712/b377712.txt">Table of n, a(n) for n = 1..10000</a>
%F 1 <= n/a(n) <= 9.
%e For n = 42: the divisors of 42 are 1, 2, 3, 6, 7, 14, 21, 42; the least divisor with 2 digits is 14, so a(42) = 14.
%p f:= proc(n) local d,t;
%p t:= ilog10(n);
%p min(select(d -> ilog10(d)=t, numtheory:-divisors(n)))
%p end proc:
%p map(f, [$1..100]); # _Robert Israel_, Nov 06 2024
%t s={};Do[m=0;d=Divisors[n];Until[Length[IntegerDigits[d[[m]]]]==Length[IntegerDigits[n]],m++];AppendTo[s,d[[m]]],{n,67}];s (* _James C. McMahon_, Nov 06 2024 *)
%o (PARI) a(n, base = 10) = { my (w = #digits(n, base)); forstep (x = base-1, 1, -1, if (n%x==0 && #digits(n/x)==w, return (n/x););); }
%o (Python)
%o def A377712(n): return n//next(d for d in range(n//10**(len(str(n))-1),0,-1) if not n%d) # _Chai Wah Wu_, Nov 06 2024
%Y Cf. A055642, A109940.
%K nonn,base,easy
%O 1,10
%A _Rémy Sigrist_, Nov 04 2024