OFFSET
1,3
COMMENTS
All odd squares have the form 8*n + 1.
REFERENCES
G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers, 5th ed., Oxford Univ. Press, 1979, theorem 14 and ch. 4.5
EXAMPLE
8*0 + 1 = 1 = 1^2, so 0 is a term;
8*1 + 1 = 9 = 3^2, so 1 is a term;
8*2 + 1 = 17 = prime(7), so 2 is a term;
8*3 + 1 = 25 = 5^2, so 3 is a term;
8*4 + 1 = 33 is neither prime nor square, so 4 is not a term;
8*5 + 1 = 41 = prime(13), so 5 is a term.
MAPLE
q:= k-> (t-> isprime(t) or issqr(t))(8*k+1):
select(q, [$0..200])[]; # Alois P. Heinz, Feb 25 2020
MATHEMATICA
Select[Range[0, 150], PrimeQ[(m = 8*# + 1)] || IntegerQ @ Sqrt[m] &] (* Amiram Eldar, Feb 29 2020 *)
PROG
(Rexx)
S = 0 ; U = 1 ; P = 1
do N = 1 while length( S ) < 256
C = 8 * N + 1
do I = U by 2
K = I * I ; if K > C then leave I
U = I ; if K < C then iterate I
S = S || ', ' N ; iterate N
end I
do I = P
K = PRIME( I ) ; if K > C then leave I
P = I ; if K < C then iterate I
S = S || ', ' N ; iterate N
end I
end N
say S ; return S
(PARI) isok(k) = my(x=8*k+1); isprime(x) || issquare(x); \\ Michel Marcus, Feb 27 2020
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Frank Ellermann, Feb 23 2020
STATUS
approved