A286328 Least integer k such that the area of the triangle (prime(n), k, k+1) is an integer.
4, 3, 24, 60, 14, 9, 180, 264, 20, 480, 19, 84, 924, 1104, 51, 1740, 155, 2244, 2520, 2664, 3120, 3444, 99, 51, 51, 5304, 5724, 65, 399, 8064, 8580, 9384, 9660, 221, 11400, 12324, 13284, 13944, 14964, 16020, 819, 18240, 194, 99, 19800, 22260, 24864, 25764, 26220
Offset: 2
Keywords
Examples
a(4) = 24 because the area of the triangle (prime(4), 24, 25) = (7, 24, 25) = sqrt(28*(28-7)*(28-24)*(28-25)) = 84, where the semiperimeter 28 = (7+24+25)/2.
Links
- Chai Wah Wu, Table of n, a(n) for n = 2..1000
Programs
-
Maple
nn:=10^7: for n from 2 to 50 do: a:=ithprime(n):ii:=0: for k from 1 to nn while(ii=0) do: p:=(a+2*k+1)/2:q:=p*(p-a)*(p-k)*(p-k-1): if q>0 and floor(sqrt(q))=sqrt(q) then ii:=1: printf(`%d, `,k): else fi: od: od:
-
Mathematica
Do[kk=0;Do[s=(Prime[n]+2k+1)/2;If[IntegerQ[s],area2=s(s-Prime[n])(s-k)(s-k-1);If[area2>0&&kk==0&&IntegerQ[Sqrt[area2]],Print[n," ",k];kk=1]],{k,1,3*10^4}],{n,2,10}] (* or *) a[n_] := Block[{p = Prime@n, k}, k = (p + 1)/2; While[! IntegerQ@ Sqrt[(4 k^2 - p^2 + 4 k + 1) (p^2 - 1)/16], k++]; k]; a /@ Range[2, 50] (* Giovanni Resta, May 07 2017 *)
-
Python
from _future_ import division from sympy import prime from gmpy2 import is_square def A286328(n): # assumes n >= 2 p, area = prime(n), 0 k, q, kq = (p + 1)//2, (p**2 - 1)//2, (p - 1)*(p + 1)**2//4 while True: area += kq if is_square(area): return k k += 1 kq += q # Chai Wah Wu, May 15 2017
Comments