OFFSET
1,1
EXAMPLE
5 is in the sequence because 5 = 1^2 + 2^2.
13 is in the sequence because 13 = 2^2 + 3^2.
MATHEMATICA
list = {};
squares = Subsets[{1, 2, 3, 4, 5, 6, 7, 8, 9}]^2;
For[i=1, iā¤Length[squares], i++,
If[PrimeQ[Total[squares[[i]] ]], AppendTo[list, Total[squares[[i]] ]]]];
Intersection[list] (* Robert Price, Dec 20 2016 *)
Select[Union[Total/@Subsets[Range[9]^2, {2, 9}]], PrimeQ] (* Harvey P. Dale, Jul 20 2020 *)
PROG
(MiniZinc)
% In the modeling language MiniZinc each prime number n belonging to the sequence produces a satisfactory solution for this model:
include "all_different.mzn";
int: n;
var 1..9: A;
var 1..9: B;
var 1..9: C;
var 1..9: D;
var 1..9: E;
var 1..9: F;
var 1..9: G;
var 1..9: H;
var 1..9: I;
var 0..1: nA; var 0..1: nB; var 0..1: nC; var 0..1: nD; var 0..1: nE; var 0..1: nF; var 0..1: nG; var 0..1: nH; var 0..1: nI;
solve satisfy;
constraint all_different([A, B, C, D, E, F, G, H, I]) /\
n=(A*A*nA+B*B*nB+C*C*nC+D*D*nD+E*E*nE+F*F*nF+G*G*nG+H*H*nH+I*I*nI)
(Python)
from sympy import isprime
from itertools import chain, combinations
def powerset(s): # skipping empty set and singletons
return chain.from_iterable(combinations(s, r) for r in range(2, len(s)+1))
def aupto(limit):
sosds = set(sum(ss) for ss in powerset([i**2 for i in range(1, 10)]))
return sorted(filter(isprime, (t for t in sosds if t <= limit)))
print(aupto(281)) # Michael S. Branicky, May 13 2021
CROSSREFS
KEYWORD
nonn,base,fini,full
AUTHOR
Pierandrea Formusa, Dec 20 2016
STATUS
approved