cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A306678 Number of distinct triangles with prime sides and largest side = prime(n).

This page as a plain text file.
%I A306678 #23 Apr 24 2025 13:23:10
%S A306678 1,3,4,6,7,11,13,18,21,22,29,30,37,46,53,56,60,71,75,87,101,105,118,
%T A306678 124,123,139,157,173,193,209,186,207,219,244,241,264,277,291,318,329,
%U A306678 344,371,373,405,433,465,447,440,474,511,545,563,597,602,623,645
%N A306678 Number of distinct triangles with prime sides and largest side = prime(n).
%H A306678 Felix Huber, <a href="/A306678/b306678.txt">Table of n, a(n) for n = 1..10000</a>
%F A306678 a(n) = A306676(n) + A306677(n).
%e A306678 For n=1, there is 1 triangle: {2, 2, 2}, with largest side prime(1) = 2.
%e A306678 For n=2, there are 3 triangles: {2, 2, 3}, {2, 3, 3}, {3, 3, 3}, with largest side prime(2) = 3.
%e A306678 For n=4, there are 6 triangles :{2, 7, 7}, {3, 5, 7}, {3, 7, 7}, {5, 5, 7}, {5, 7, 7}, {7, 7, 7}, with largest side prime(4) = 7. Total = 6 = a(4).
%e A306678 For n=5, largest side = prime(n) = 11. Triangles are {{2, 11, 11}, {3, 11, 11}, {5, 7, 11}, {5, 11, 11}, {7, 7, 11}, {7, 11, 11}, {11, 11, 11}}. Total = 7 = a(5).
%p A306678 #nType=1 for acute triangles, nType=2 for obtuse triangles
%p A306678 #nType=0 for both triangles
%p A306678 CountPrimeTriangles := proc (n, nType := 1)
%p A306678   local aa, oo, j, k, sg, a, b, c, tt, lAcute;
%p A306678   aa := {}; oo := {};
%p A306678   a := ithprime(n);
%p A306678   for j from n by -1 to 1 do
%p A306678     b := ithprime(j);
%p A306678     for k from j by -1 to 1 do
%p A306678       c := ithprime(k);
%p A306678       if a < b+c and abs(b-c) < a and b < c+a and abs(c-a) < b and c < a+b and abs(a-b) < c then
%p A306678         lAcute := evalb(0 < b^2+c^2-a^2);
%p A306678         tt := sort([a, b, c]);
%p A306678         if lAcute then aa := {op(aa), tt} else oo := {op(oo), tt} end if
%p A306678       end if
%p A306678     end do
%p A306678   end do;
%p A306678   return sort(`if`(nType = 1, aa, `if`(nType = 2, oo, `union`(aa, oo))))
%p A306678 end proc:
%p A306678 # Alternative:
%p A306678 with(NumberTheory):
%p A306678 A306678:=proc(n)
%p A306678     local a,i,p;
%p A306678     if n=1 then
%p A306678         1
%p A306678     else
%p A306678         a:=0;
%p A306678         p:=ithprime(n);
%p A306678         for i from pi(nextprime((p-1)/2)) to n do
%p A306678             a:=a+i-pi(nextprime(p-ithprime(i)))+1;
%p A306678         od;
%p A306678             return a
%p A306678 	fi;		
%p A306678 end proc;
%p A306678 seq(A306678(n),n=1..56); # _Felix Huber_, Apr 19 2025
%Y A306678 Cf. A306673, A306674, A306676, A306677, A366398, A378819, A379033.
%K A306678 nonn
%O A306678 1,2
%A A306678 _César Eliud Lozada_, Mar 04 2019