OFFSET
1,2
COMMENTS
A subsequence of A234334.
EXAMPLE
5 is in the sequence because the following three are perfect squares: 5-4=1, 5-1=4, 9-5=4.
65 is in the sequence because the following three are perfect squares: 65-64=1, 65-49=16, 81-65=16, where 49, 64, 81 are the three squares nearest to 65.
MATHEMATICA
ps3Q[n_]:=AllTrue[Take[Sort[Abs[n-(Floor[Sqrt[n]]+{-2, -1, 0, 1, 2})^2]], 3], IntegerQ[Sqrt[#]]&]; Join[ {0}, Select[Range[2, 10^6], ps3Q]] (* Harvey P. Dale, Jul 03 2024 *)
PROG
(C)
#include <stdio.h>
#include <math.h>
typedef unsigned long long U64;
U64 isSquare(U64 a) {
U64 r = sqrt(a);
return r*r==a;
}
int main() {
for (U64 n=0; ; ++n) {
U64 r = sqrt(n);
if (r*r==n && n) --r;
if (isSquare(n-r*r) && isSquare((r+1)*(r+1)-n)) {
U64 rp = (r+2)*(r+2)-n;
r = n-(r-1)*(r-1);
if (n<=1 || rp<r) r = rp;
if (isSquare(r)) printf("%llu, ", n);
}
}
return 0;
}
CROSSREFS
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, Dec 23 2013
STATUS
approved