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”).

A102600
Largest prime which can be formed from digits of n^2, or 0, if no prime.
1
0, 0, 0, 61, 5, 3, 0, 0, 0, 0, 211, 41, 691, 691, 5, 5, 829, 43, 631, 0, 41, 0, 59, 67, 5, 67, 97, 487, 41, 0, 691, 4201, 809, 6151, 2521, 691, 9631, 4441, 521, 601, 8161, 761, 8941, 9631, 5, 6211, 2029, 43, 4201, 5, 601, 4027, 8209, 691, 5023, 6133, 439, 6343, 8431, 3
OFFSET
1,4
LINKS
FORMULA
a(n) = A101991(n^2). - Michel Marcus, Oct 05 2013
EXAMPLE
a(11)=211 because 211 is the largest prime which can be made from digits of 11*11=121: {1,1,2}.
MAPLE
f:= proc(n) local L, N, d, i, j, S, s, p;
L:= convert(n^2, base, 10);
N:= nops(L);
for d from N to 1 by -1 do
S:= sort(combinat:-permute(L, d));
for i from nops(S) to 1 by -1 do
s:= S[i];
p:= add(s[j]*10^(d-j), j=1..d);
if isprime(p) then return p fi
od od;
0
end proc:
map(f, [$1..100]); # Robert Israel, Jan 10 2024
MATHEMATICA
a[n_]:=Max[0, Select[FromDigits/@Permutations[IntegerDigits[n^2], {1, IntegerLength[n^2]}], PrimeQ]]; Table[a[n], {n, 60}] (* James C. McMahon, Jan 09 2024 *)
CROSSREFS
Cf. A101991.
Sequence in context: A051322 A345224 A198189 * A316918 A077331 A106426
KEYWORD
base,easy,nonn,look
AUTHOR
Zak Seidov, Jan 29 2005
EXTENSIONS
Data corrected for n={18,33,39,57} by James C. McMahon, Jan 10 2024.
STATUS
approved