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-3 of 3 results.

A048853 Number of primes (different from n) that can be produced by altering one digit of decimal expansion of n (without changing the number of digits).

Original entry on oeis.org

4, 3, 3, 4, 3, 4, 3, 4, 4, 4, 7, 4, 8, 4, 4, 4, 7, 4, 7, 2, 7, 2, 6, 2, 2, 2, 7, 2, 5, 2, 5, 2, 8, 2, 2, 2, 5, 2, 7, 3, 6, 3, 7, 3, 3, 3, 6, 3, 8, 2, 7, 2, 6, 2, 2, 2, 7, 2, 5, 2, 5, 2, 8, 2, 2, 2, 5, 2, 7, 3, 6, 3, 7, 3, 3, 3, 8, 3, 6, 2, 7, 2, 6, 2, 2, 2, 7, 2, 5, 1, 6, 1, 7, 1, 1, 1, 4, 1, 6, 4, 10, 4, 8, 4, 4
Offset: 1

Views

Author

Keywords

Comments

a(A192545(n)) = 0. - Reinhard Zumkeller, Jul 05 2011

Examples

			Altering the number 13 gives eight primes: 11, 17, 19, 23, 43, 53, 73, 83, so a(13)=8.
		

Crossrefs

Programs

  • Haskell
    import Data.List (inits, tails, nub)
    a048853 n = (sum $ map (a010051 . read) $ tail $ nub $ concat $ zipWith
      (\its tls -> map ((\xs ys d -> xs ++ (d:ys)) its tls) "0123456789")
        (map init $ tail $ inits $ show n) (tail $ tails $ show n)) - a010051 n
    -- Reinhard Zumkeller, Jul 05 2011
    
  • Maple
    A048853 := proc(n::integer) local resul,ddigs,d,c,tmp ; resul := 0 ; ddigs := convert(n,base,10) ; for d from 1 to nops(ddigs) do for c from 0 to 9 do if c = 0 and d = nops(ddigs) then continue ; else if c <> op(d,ddigs) then tmp := [op(1..d-1,ddigs),c,op(d+1..nops(ddigs),ddigs)] ; tst := sum(op(i,tmp)*10^(i-1),i=1..nops(tmp)) ; if isprime(tst) then resul := resul+1 ; fi ; fi ; fi ; od : od ; RETURN(resul) ; end: for n from 1 to 90 do printf("%d,",A048853(n)) ; od ; # R. J. Mathar, Apr 25 2006
  • Mathematica
    a[n_] := Module[{idn = IntegerDigits[n], id, np = 0}, Do[id = idn; If[ id[[j]] != k, id[[j]] = k; If[ id[[1]] != 0 && PrimeQ[ FromDigits[id]], np = np + 1]], {j, 1, Length[idn]}, {k, 0, 9}]; np]; Table[a[n], {n, 1, 105}] (* Jean-François Alcover, Dec 01 2011 *)
  • Python
    from sympy import isprime
    def h1(n): # hamming distance 1 neighbors of n, not starting with 0
        s = str(n); d = "0123456789"; L = len(s)
        yield from (int(s[:i]+c+s[i+1:]) for c in d for i in range(L) if c!=s[i] and not (i==0 and c=="0"))
    def a(n): return sum(1 for k in h1(n) if isprime(k))
    print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Jul 31 2022

A158124 Weakly prime numbers (or isolated primes): changing any one decimal digit always produces a composite number, with restriction that first digit may not be changed to a 0.

Original entry on oeis.org

294001, 505447, 584141, 604171, 929573, 971767, 1062599, 1282529, 1524181, 2017963, 2474431, 2690201, 3070663, 3085553, 3326489, 4393139, 5152507, 5285767, 5564453, 5575259, 5974249, 6173731, 6191371, 6236179, 6463267, 6712591, 7204777, 7469789, 7469797, 7810223
Offset: 1

Views

Author

Eric W. Weisstein, Mar 13 2009

Keywords

Comments

The definition could be restated as "primes p with d digits such that there is no prime q with at most d digits at Hamming distance 1 from p (in base 10)". - N. J. A. Sloane, May 06 2019
For the following values of k, 5, 6, 7, 8, 9, 10, the number of terms < 10^k in this sequence is 0, 6, 43, 406, 3756, 37300. - Jean-Marc Rebert, Nov 10 2015

Crossrefs

Cf. A050249, A158125 (weakly primes), A186995, A192545.

Programs

  • Maple
    filter:= proc(n)
      local L,i,d,ds;
      if not isprime(n) then return false fi;
      L:= convert(n,base,10);
      for i from 1 to nops(L) do
        if i = nops(L) then ds:= {$1..9} minus {L[i]}
        elif i = 1 then ds:= {1,3,7,9} minus {L[i]}
        else ds:= {$0..9} minus {L[i]}
        fi;
        for d in ds do
          if isprime(n + (d - L[i])*10^(i-1)) then return false fi;
        od
      od;
      true
    end proc:
    select(filter, [seq(i,i=11..10^6,2)]); # Robert Israel, Dec 15 2015
  • Mathematica
    Select[Prime@ Range[10^5], Function[n, Function[w, Total@ Map[Boole@ PrimeQ@ # &, DeleteCases[#, n]] &@ Union@ Flatten@ Map[Function[d, FromDigits@ ReplacePart[w, d -> #] & /@ If[d == 1, #, Prepend[#, 0]] &@ Range@ 9], Range@ Length@ w] == 0]@ IntegerDigits@ n]] (* Michael De Vlieger, Dec 13 2016 *)
  • PARI
    isokp(n) = {v = digits(n); for (k=1, #v, w = v; if (k==1, idep = 1, idep=0); for (j=idep, 9, if (j != v[k], w[k] = j; ntest = subst(Pol(w), x, 10); if (isprime(ntest), return(0));););); return (1);}
    lista(nn) = {forprime(p=2, nn, if (isokp(p), print1(p, ", ")););} \\ Michel Marcus, Dec 15 2015
    
  • Python
    from sympy import isprime
    def h1(n): # hamming distance 1 neighbors of n, not starting with 0
        s = str(n); d = "0123456789"; L = len(s)
        yield from (int(s[:i]+c+s[i+1:]) for c in d for i in range(L) if c!=s[i] and not (i==0 and c=="0"))
    def ok(n): return isprime(n) and all(not isprime(k) for k in h1(n))
    print([k for k in range(10**6) if ok(k)]) # Michael S. Branicky, Jul 31 2022

Extensions

Edited by Charles R Greathouse IV, Aug 02 2010
Missing a(3385) inserted into b-file by Andrew Howroyd, Feb 23 2018

A382137 Smallest integer that cannot be converted to a multiple of n by changing at most one of its decimal digit.

Original entry on oeis.org

545, 51, 44, 31, 21, 21, 22, 21, 21, 11, 15, 11, 11, 11, 11, 11, 12, 11, 11, 11, 14, 11, 11, 11, 11, 11, 11, 11, 11, 11, 13, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12
Offset: 11

Views

Author

Mickaël Launay, Mar 27 2025

Keywords

Comments

a(n) is not defined for n<11 since any integer can be converted to a multiple of n by changing its last digit.
For all n, a(n)>=11, since any number <=10 ca be converted to 0 which is a multiple of n.
For n>=42, a(n)=11, except for a(51)=a(61)=a(71)=a(81)=a(91)=12. Especially a(n)=11 for all n>=100 because 11 is the first integer that cannot be converted to 0 or a 3-digit number.

Examples

			For n=12, any number<50 can be converted to a multiple of 12 by changing its last digit. Since a) there is no multiple of 12 between 50 and 59 so changing the last digit is useless, b) 50 can be converted to 60=5*12 and c) changing the "5" of 51 gives only odd (non multiples of 12) numbers, then a(12)=51.
		

Crossrefs

Programs

  • Python
    import math
    def test(N,M):
       t = True
       for i in range(0,math.floor(math.log(N,10))+1):
          for j in range(0,10): t = t and ((N+(j-N // 10**i % 10)*10**i)%M != 0)
       return t
    for M in range(11,100):
       N = 1
       while (not test(N,M)): N += 1
       print(N, end=', ')
Showing 1-3 of 3 results.