A089392 Magnanimous primes: primes with the property that inserting a "+" in any place between two digits yields a sum which is prime.
2, 3, 5, 7, 11, 23, 29, 41, 43, 47, 61, 67, 83, 89, 101, 227, 229, 281, 401, 443, 449, 467, 601, 607, 647, 661, 683, 809, 821, 863, 881, 2221, 2267, 2281, 2447, 4001, 4027, 4229, 4463, 4643, 6007, 6067, 6803, 8009, 8221, 8821, 20261, 24407, 26881, 28429, 40427
Offset: 1
Examples
2267 is a member which gives primes 2+267 = 269, 22+67 = 89, 226+7 = 233 and 2267 itself.
Links
- Zak Seidov, Table of n, a(n) for n = 1..84
- Eric Angelini et al., Insert "+" and always get a prime, Dec
- 2014
- Giovanni Resta, magnanimous numbers, 2013.
- Carlos Rivera, Puzzle 401. Magnanimous primes, 2007, The Prime Puzzles & Problems Connection.
Programs
-
Maple
with(combinat): ds:=proc(s) local j: RETURN(add(s[j]*10^(j-1),j=1..nops(s))):end: for d from 1 to 6 do sch:=[seq([1,op(i),d+1],i=[[],seq([j],j=2..d)])]: for n from 10^(d-1) to 10^d-1 do sn:=convert(n,base,10): fl:=0: for s in sch do m:=add(j,j=[seq(ds(sn[s[i]..s[i+1]-1]),i=1..nops(s)-1)]): if not isprime(m) then fl:=1: break fi od: if fl=0 then printf("%d, ",n) fi od od: # C. Ronaldo
-
Mathematica
mpQ[n_]:=Module[{idn=IntegerDigits[n],len},len=Length[idn];And@@PrimeQ[ Table[ FromDigits[Take[idn,i]]+FromDigits[Take[idn,-(len-i)]],{i,len}]]]; Select[Range[41000],mpQ] (* Harvey P. Dale, Nov 06 2013 *)
-
PARI
is_A089392(n)={!for(i=1,#Str(n),ispseudoprime([1,1]*(divrem(n,10^i)))||return)} \\ M. F. Hasler, Dec 25 2014
-
Python
from sympy import isprime def ok(n): if not isprime(n): return False s = str(n) return all(isprime(int(s[:i])+int(s[i:])) for i in range(1, len(s))) print([k for k in range(357) if ok(k)]) # Michael S. Branicky, Oct 14 2024
Extensions
Corrected and extended by C. Ronaldo (aga_new_ac(AT)hotmail.com), Dec 25 2004
Comments edited by Zak Seidov, Jan 29 2013
Edited by M. F. Hasler, Dec 25 2014
Comments