login
a(n) is the largest number of distinct integer-sided right triangles in which some n-digit number can appear as the length of a side.
0

%I #33 Sep 06 2022 15:34:56

%S 2,14,68,203,476,1421,3293,7910,20060,39509,89324,206711,442907,

%T 803924,1722464,3198608,6820523,13434254,27901259,50222267

%N a(n) is the largest number of distinct integer-sided right triangles in which some n-digit number can appear as the length of a side.

%H Zhihu, <a href="https://www.zhihu.com/question/531237744">For integers from 1 to 100, which one can compose the most Pythagorean triangle?</a>

%e a(2)=14 because there exist 14 distinct integer-sided right triangles with the 2-digit number 60 as the length of a side, i.e., (11,60,61), (25,60,65), (32,60,68), (36,48,60), (45,60,75), (60,63,87), (60,80,100), (60,91,109), (60,144,156), 60,175,185), (60,221,229), (60,297,303), (60,448,452), and (60,899,901), and no 2-digit number is the length of a side of more than 14 distinct integer-sided right triangles.

%o (Python)

%o from sympy import factorint

%o def s(n):

%o f=factorint(n)

%o d, q=(list(f.keys()), list(f.values()))

%o (a, b, c, x)=(0, 1, 1, 0)

%o if(d[0]==2):

%o a, x=(0, 1)

%o if q[0]>1:

%o a=q[0]-1

%o for p in range(x, len(d)):

%o b*=(1+2*q[p])

%o if d[p]%4==1:

%o c*=(1+2*q[p])

%o return((b-1)//2+a*b+(c-1)//2)

%o def a(n):

%o max=0

%o for i in range(1+10**(n-1), 10**n):

%o if s(i)>max:

%o k,max=(i,s(i))

%o return(n,[k,max])

%o for i in range(1,6):

%o print (a(i))

%o # (thanks to _Zhao Hui Du_ for help in the derivation of this function)

%Y Cf. A046081, A269929, A353875.

%K nonn,more

%O 1,1

%A _Zhining Yang_, Jun 26 2022