2
$\begingroup$

How do I print only the values of p which are all True?

In addition, is this an efficient use of a Loop in this situation or can this be improved without using a lietral for loop?

For[i = 10200, i <= 10500, i++, v = Divisors[i]; p = PrimeQ[v + (i/v)]; Print[i]; Print[p]] 

Thanks.

$\endgroup$
0

1 Answer 1

3
$\begingroup$
Clear["Global`*"]; test[i_] := AllTrue[Divisors[i], PrimeQ[# + (i/#)] &]; Select[Range[10200, 10500], test] (* {10222, 10390, 10462} *) 
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.