cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A252996 Magnanimous numbers: numbers such that the sum obtained by inserting a "+" anywhere between two digits gives a prime.

This page as a plain text file.
%I A252996 #40 Dec 23 2024 14:53:44
%S A252996 0,1,2,3,4,5,6,7,8,9,11,12,14,16,20,21,23,25,29,30,32,34,38,41,43,47,
%T A252996 49,50,52,56,58,61,65,67,70,74,76,83,85,89,92,94,98,101,110,112,116,
%U A252996 118,130,136,152,158,170,172,203,209,221,227,229,245,265,281,310,316,334,338,356
%N A252996 Magnanimous numbers: numbers such that the sum obtained by inserting a "+" anywhere between two digits gives a prime.
%C A252996 Inclusion of the single-digit terms is conventional: here the property is voidly satisfied since no sum can be constructed by inserting a + sign between two digits, therefore all possible sums are prime. (It is not allowed to prefix a leading zero (e.g., to forbid 4 = 04 = 0+4) since in that case all terms must be prime and one would get A089392.)
%C A252996 All terms different from 20 and not of the form 10^k+1 have the last digit of opposite parity than that of all other digits.
%C A252996 The sequence is marked as "finite", although we do not have a rigorous proof for this, only very strong evidence (numerical and probabilistic). G. Resta has checked that up to 5e16 the only magnanimous numbers with more than 11 digits are 5391391551358 and 97393713331910, the latter being probably the largest element of this sequence. In that case the 10+33+79+104+112+96+71+35+18+6+5+0+1+1 = 571 terms listed in Wilson's b-file are the complete list, which is what the keyword "full" stands for.
%H A252996 Robert G. Wilson v, <a href="/A252996/b252996.txt">Table of n, a(n) for n = 1..571</a>
%H A252996 Hans Havermann, in reply to Eric Angelini, <a href="https://web.archive.org/web/*/http://list.seqfan.eu/oldermail/seqfan/2014-December/014188.html">Insert "+" and always get a prime</a>, Dec 2014
%H A252996 Giovanni Resta, <a href="http://www.numbersaplenty.com/set/magnanimous_number/">magnanimous numbers</a>, 2013.
%H A252996 Carlos Rivera, <a href="http://www.primepuzzles.net/puzzles/puzz_401.htm">Puzzle 401. Magnanimous primes</a>, 2007, The Prime Puzzles & Problems Connection.
%e A252996 245 is in the sequence because the numbers 2 + 45 = 47 and 24 + 5 = 29 are both prime. See the first comment for the single-digit terms.
%p A252996 filter:= proc(n) local d;
%p A252996   for d from 1 to ilog10(n)-1 do
%p A252996     if not isprime(floor(n/10^d)+(n mod 10^d)) then return false fi
%p A252996   od:
%p A252996   true
%p A252996 end proc:
%p A252996 select(filter, [$0..10^5]); # _Robert Israel_, Dec 25 2014
%t A252996 fQ[n_] := Block[{idn = IntegerDigits@ n, lng = Floor@ Log10@ n}, Union@ PrimeQ@ Table[ FromDigits[ Take[ idn, i]] + FromDigits[ Take[ idn, -lng + i -1]], {i, lng}] == {True}]; (* or *)
%t A252996 fQ[n_] := Block[{lng = Floor@ Log10@ n}, Union@ PrimeQ[ Table[ Floor[n/10^k] + Mod[n, 10^k], {k, lng}]] == {True}];
%t A252996 fQ[2] = fQ[3] = fQ[5] = fQ[7] = True; Select[ Range@ 500, fQ]
%t A252996 (* _Robert G. Wilson v_, Dec 26 2014 *)
%t A252996 mnQ[n_]:=AllTrue[Total/@Table[FromDigits/@TakeDrop[IntegerDigits[n],i],{i,IntegerLength[n]-1}],PrimeQ]; Join[Range[0,9],Select[Range[ 10,400], mnQ]] (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, May 26 2017 *)
%o A252996 (PARI) is(n)={!for(i=1,#Str(n)-1,ispseudoprime([1,1]*(divrem(n,10^i)))||return)}
%o A252996 t=0;vector(100,i,until(is(t++),);t)
%o A252996 (Python)
%o A252996 from sympy import isprime
%o A252996 def ok(n):
%o A252996     s = str(n)
%o A252996     return all(isprime(int(s[:i])+int(s[i:])) for i in range(1, len(s)))
%o A252996 print([k for k in range(357) if ok(k)]) # _Michael S. Branicky_, Oct 14 2024
%Y A252996 Cf. A089392, A089393, A089394, A028834, A182175, A088134, A221699, A227823.
%K A252996 nonn,base,nice,fini,full
%O A252996 1,3
%A A252996 _M. F. Hasler_, Dec 25 2014