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.

Showing 1-2 of 2 results.

A179549 Primes p such that p minus the sum of the square of its digits yields a prime.

Original entry on oeis.org

13, 53, 127, 233, 257, 293, 457, 521, 541, 547, 587, 857, 983, 1151, 1153, 1429, 1481, 1489, 1511, 1553, 1559, 1579, 1621, 1753, 1861, 2099, 2129, 2143, 2239, 2273, 2341, 2347, 2383, 2411, 2417, 2459, 2549, 2657, 2677, 2729, 2741, 2789, 2837, 2897, 2927
Offset: 1

Views

Author

Carmine Suriano, Jul 19 2010

Keywords

Comments

This sequence differs from A076163 which takes the absolute value of the difference.

Examples

			a(5)=257 since 257-(2^2+5^2+7^2)=179 is a prime.
		

Crossrefs

Programs

  • Mathematica
    ssdQ[n_]:=Module[{c=n-Total[IntegerDigits[n]^2]},Positive[c]&&PrimeQ[c]]; Select[Prime[Range[500]],ssdQ] (* Harvey P. Dale, Dec 26 2018 *)
  • PARI
    isok(n) = {if (isprime(n), digs = digits(n, 10); isprime(n - sum(i=1, #digs, digs[i]^2));, 0)} \\ Michel Marcus, Jul 18 2013

Extensions

A-number typo and signs in the example corrected - R. J. Mathar, Oct 23 2010

A179550 Primes p such that p plus or minus the sum of its digits squared yields a prime in both cases.

Original entry on oeis.org

13, 127, 457, 1429, 1553, 1621, 2273, 2341, 2837, 4129, 4231, 4561, 4813, 5119, 5519, 5531, 6121, 6451, 6547, 8161, 8167, 8219, 8237, 8783, 8819, 8831, 8941, 9511, 10267, 10559, 11299, 11383, 12809, 13183, 15091, 15569, 16573, 17569, 17659, 18133
Offset: 1

Views

Author

Carmine Suriano, Jul 19 2010

Keywords

Examples

			a(5)=1553 since 1553+(1^2+5^2+5^2+3^2)=1553+60=1613 is a prime AND 1553-(1^2+5^2+5^2+3^2)=1553-60=1493 is a prime again.
		

Crossrefs

Programs

  • Maple
    filter:= proc(p) local t,r;
    if not isprime(p) then return false fi;
    r:= add(t^2, t=convert(p,base,10));
    isprime(p+r) and isprime(p-r);
    end proc:
    select(filter, [seq(i,i=3..20000,2)]); # Robert Israel, Mar 30 2021
  • Mathematica
    Select[Prime[Range[2100]],AllTrue[#+{Total[IntegerDigits[#]^2],-Total[ IntegerDigits[ #]^2]},PrimeQ]&] (* Harvey P. Dale, Aug 07 2021 *)
  • PARI
    sumdd(n) = {digs = digits(n, 10); return (sum(i=1, #digs, digs[i]^2));}
    lista(nn) = {forprime(p=2, nn, s = sumdd(p); if (isprime(p+s) && isprime(p-s), print1(p, ", ")););} \\ Michel Marcus, Jul 25 2013
    
  • Python
    from sympy import isprime, primerange
    def sumdd(n): return sum(int(d)**2 for d in str(n))
    def list(nn):
      for p in primerange(2, nn+1):
        s = sumdd(p)
        if isprime(p-s) and isprime(p+s): print(p, end=", ")
    list(18133) # Michael S. Branicky, Mar 30 2021 after Michel Marcus
Showing 1-2 of 2 results.