login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Prime numbers p with the property that p is the sum of the squares of two or more distinct one-digit numbers.
0

%I #25 May 13 2021 11:49:52

%S 5,13,17,29,37,41,53,59,61,71,73,79,83,89,97,101,103,107,109,113,127,

%T 131,137,139,149,151,163,167,179,181,191,197,199,211,223,227,229,233,

%U 239,251,269,271,281

%N Prime numbers p with the property that p is the sum of the squares of two or more distinct one-digit numbers.

%e 5 is in the sequence because 5 = 1^2 + 2^2.

%e 13 is in the sequence because 13 = 2^2 + 3^2.

%t list = {};

%t squares = Subsets[{1,2,3,4,5,6,7,8,9}]^2;

%t For[i=1, i≤Length[squares], i++,

%t If[PrimeQ[Total[squares[[i]] ]], AppendTo[list, Total[squares[[i]] ]]]];

%t Intersection[list] (* _Robert Price_, Dec 20 2016 *)

%t Select[Union[Total/@Subsets[Range[9]^2,{2,9}]],PrimeQ] (* _Harvey P. Dale_, Jul 20 2020 *)

%o (MiniZinc)

%o % In the modeling language MiniZinc each prime number n belonging to the sequence produces a satisfactory solution for this model:

%o include "all_different.mzn";

%o int: n;

%o var 1..9: A;

%o var 1..9: B;

%o var 1..9: C;

%o var 1..9: D;

%o var 1..9: E;

%o var 1..9: F;

%o var 1..9: G;

%o var 1..9: H;

%o var 1..9: I;

%o 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;

%o solve satisfy;

%o constraint all_different([A,B,C,D,E,F,G,H,I]) /\

%o 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)

%o (Python)

%o from sympy import isprime

%o from itertools import chain, combinations

%o def powerset(s): # skipping empty set and singletons

%o return chain.from_iterable(combinations(s, r) for r in range(2, len(s)+1))

%o def aupto(limit):

%o sosds = set(sum(ss) for ss in powerset([i**2 for i in range(1, 10)]))

%o return sorted(filter(isprime, (t for t in sosds if t <= limit)))

%o print(aupto(281)) # _Michael S. Branicky_, May 13 2021

%K nonn,base,fini,full

%O 1,1

%A _Pierandrea Formusa_, Dec 20 2016