OFFSET
1,1
COMMENTS
The value d is the square of the length of the diagonal of a trapezoid with a height and bases that are consecutive primes, respectively. The diagonal length is calculated using the Pythagorean theorem, but this distance is squared so that the value is an integer.
LINKS
Aaron T Cowan, Table of n, a(n) for n = 1..500
FORMULA
a(n) = prime(n)^2 + (prime(n+2)-prime(n+1))^2.
EXAMPLE
p(2)=3
_ _ _ _
a(1): | \ d^2=2^2+(5-3)^2=8
p(1)=2 |_ _ _ _ _\
p(3)=5
p(3)=5
_ _ _ _ _ _
a(2): | \ d^2=3^2 + (7-5)^2 = 9+4 = 13
p(2)=3 | \
|_ _ _ _ _ _ _\
p(4)=7
a(3)= 5^2+(11-7)^2 = 25+16 = 41
a(7)= 17^2+(23-19)^2=305 = 5*61
MATHEMATICA
Map[(#[[1]]^2 + (#[[3]] - #[[2]])^2) &, Partition[Prime[Range[50]], 3, 1]] (* Amiram Eldar, Feb 24 2023 *)
PROG
(MATLAB) %shorter 1 line version
arrayfun(@(p) p^2+(nextprime(nextprime(p+1)+1)-nextprime(p+1))^2, [primes(10^6)])
(PARI) a(n) = prime(n)^2 + (prime(n+2)-prime(n+1))^2; \\ Michel Marcus, Feb 23 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Aaron T Cowan, Feb 20 2023
STATUS
approved