%I #46 Aug 28 2025 22:02:14
%S 12,70,98,2002,2842,20026,91698,721786
%N Least integer k such that there are exactly n primitive Heron triangles having the same area and perimeter k.
%H BBS Math Blog, <a href="https://bbs.emath.ac.cn/forum.php?mod=viewthread&tid=17031">Primitive Heron triangles with equal perimeter and area</a> (in Chinese).
%e a(3) = 98 because there exists 3 primitive Heron triangles: {{29, 29, 40}, {25, 34, 39}, {24, 37, 37}} with same area 420 and same perimeter 98.
%e a(6) = 20026 because there exists 6 primitive Heron triangles: {{2108,8493,9425}, {2173,8398,9455}, {2261,8277,9488},{2418,8075,9533},{4123,6205,9698},{4588,5729,9709}} with same area 8410920 and same perimeter 20026.
%e a(8) = 721786 because there exists 8 primitive Heron triangles: {{188105,189428,344253}, {179133,198458,344195},{124338,256523,340925}, {116093,266029,339664}, {91448,299013,331325}, {88253,304980,328553}, {85981,310493,325312}, {85618,311627,324541}} with same area 13338605280 and same perimeter 721786.
%t sol=Association[];
%t For[n=6,n<=3000,n+=2,For[z=Ceiling[n/3],z<Floor[n/2],z++,For[x=1,x<Floor[n/3],x++,y=n-x-z;
%t If[x+y>z>=y>=x&&GCD[x,y,z]==1,p=(x+y+z)/2;A=Sqrt[p (p-x) (p-y) (p-z)];
%t If[IntegerQ[A],d=ToString@n<>"->"<>ToString@A;t={x,y,z};
%t If[KeyExistsQ[sol,d]==False,sol[d]={d}];
%t If[KeyExistsQ[sol,d],AppendTo[sol[d],t]]]]]]];
%t Do[Print[k,SelectFirst[sol,Length@#==k+1&]],{k,5}]
%o (Python)
%o from math import gcd
%o from collections import Counter
%o from itertools import count
%o from sympy.ntheory.primetest import is_square
%o def A385976(n):
%o for k in count(6,2):
%o c = Counter()
%o for x in range(1,k//3+1):
%o for y in range(x,k//2+1):
%o s, m = k>>1, x+y
%o if (m<<1)>k>=m+y and gcd(x,y,k-m)==1 and is_square(s*(a:=(s-x)*(s-y)*(m-s))):
%o c[a]+=1
%o if c[a]>n:
%o break
%o else:
%o continue
%o break
%o else:
%o if any(c[d]==n for d in c):
%o return k # _Chai Wah Wu_, Jul 25 2025
%Y Cf. A385819.
%K nonn,hard,more
%O 1,1
%A _Zhining Yang_, Jul 13 2025
%E a(7)-a(8) from _Xianwen Wang_, Jul 13 2025
%E a(3) corrected by _Xianwen Wang_, Aug 19 2025