login
A396768
a(n) is the number of primes p < q = prime(n) for which there exists an integer k such that (p, q, k) is a Heronian triangle.
0
0, 0, 1, 0, 0, 2, 0, 0, 0, 1, 0, 2, 1, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 2, 4, 1, 0, 0, 5, 2, 0, 0, 1, 0, 1, 0, 4, 0, 0, 0, 0, 2, 0, 1, 1, 0, 0, 0, 0, 3, 2, 0, 5, 0, 1, 0, 1, 0, 3, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 3, 4, 0, 0, 3, 0, 0, 1, 3, 3, 3, 0, 3, 0, 1, 0, 0, 0, 5
OFFSET
1,6
COMMENTS
Let s = (p + q + k)/2. Then (p, q, k) is Heronian iff |p - q| < k < p + q, p and q are odd primes, k is even (so that s, s - p, s - q, s - k are integers), and s*(s - p)*(s - q)*(s - k) is a perfect square.
For a fixed pair of odd primes (p, q), the number of admissible k is 0, 1, or 2. This sequence only records existence (p is counted once if at least one k exists).
If p == q == 3 (mod 4), then no k exists. If q - p == 4 (mod 8), then no k exists.
LINKS
Eric Weisstein's World of Mathematics, Heronian Triangle
EXAMPLE
a(6) = 2, since for q = prime(6) = 13 two Heronian triangles with p < 13 exist: (5, 12, 13) and (11, 13, 20).
MAPLE
f := proc(x, y) option remember;
local k, l, r, s, t, u, v;
if x = 2 then return false end if;
if irem(x, 4) = 3 and irem(y, 4) = 3 then return false end if;
if irem(x - y, 8) = 4 then return false end if;
l := max(2, abs(x - y) + 1); if type(l, odd) then l := l + 1 end if;
u := x + y - 1;
for k from l by 2 to u do
s := (x + y + k)/2; v := (x + y - k)/2; r := (-x + y + k)/2; t := (x - y + k)/2;
if issqr(s*v*r*t) then return true end if;
end do;
false
end proc:
A := proc(n) option remember;
local a, i, p, q;
q := ithprime(n); a := 0;
for i from 2 to n - 1 do
p := ithprime(i);
if f(p, q) then a := a + 1 end if;
end do;
a
end proc:
seq(A(n), n = 1 .. 88);
CROSSREFS
KEYWORD
nonn
AUTHOR
Felix Huber, Jun 05 2026
STATUS
approved