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.

A258337 Smallest prime starting with n that does not appear earlier.

This page as a plain text file.
%I A258337 #32 Nov 11 2020 19:05:36
%S A258337 11,2,3,41,5,61,7,83,97,101,113,127,13,149,151,163,17,181,19,2003,211,
%T A258337 223,23,241,251,263,271,281,29,307,31,3203,331,347,353,367,37,383,397,
%U A258337 401,419,421,43,443,457,461,47,487,491,503,5101,521,53,541,557,563,571,587,59,601,613,6203,631,641,653,661,67,683,691,701
%N A258337 Smallest prime starting with n that does not appear earlier.
%C A258337 According to a comment in A018800, every term exists. So the sequence is a permutation of the primes. Indeed, every prime p appears in the sequence either as the p-th term or earlier.
%H A258337 Peter J. C. Moses, <a href="/A258337/b258337.txt">Table of n, a(n) for n = 1..5000</a>
%H A258337 <a href="/index/Pri#piden">Index entries for primes involving decimal expansion of n</a>
%F A258337 For n>=2, a(n) >= prime(n-1). The equality holds iff prime(n-1) did not already appear as a(k), k<n.
%p A258337 N:= 100: # to get a(1) to a(N)
%p A258337 for n from 1 to N do
%p A258337   p:= n;
%p A258337   if n < 10 then
%p A258337     p1:= 0
%p A258337   else
%p A258337     p1:= A[floor(n/10)];
%p A258337   fi;
%p A258337   if isprime(p) and p > p1 then
%p A258337      A[n]:= p
%p A258337   else
%p A258337     for d from 1 while not assigned(A[n]) do
%p A258337       for i from 1 to 10^d-1 do
%p A258337         p:= 10^d*n+i;
%p A258337         if p > p1 and isprime(p) then
%p A258337            A[n]:= p;
%p A258337            break
%p A258337         fi;
%p A258337       od
%p A258337     od
%p A258337   fi
%p A258337 od:
%p A258337 seq(A[i],i=1..N); # _Robert Israel_, Jun 29 2015
%o A258337 (PARI) sw(m,n)=d1=digits(n);d2=digits(m);for(i=1,min(#d1,#d2),if(d1[i]!=d2[i],return(0)));1
%o A258337 v=[];n=1;while(n<70,k=1;while(k<10^3,p=prime(k);if(sw(p,n)&&!vecsearch(vecsort(v),p),v=concat(v,p);k=0;n++);k++));v \\ _Derek Orr_, Jun 13 2015
%o A258337 (Haskell)
%o A258337 import Data.List (isPrefixOf, delete)
%o A258337 a258337 n = a258337_list !! (n-1)
%o A258337 a258337_list = f 1 $ map show a000040_list where
%o A258337    f x pss = g pss where
%o A258337      g (qs:qss) = if show x `isPrefixOf` qs
%o A258337                      then (read qs :: Int) : f (x + 1) (delete qs pss)
%o A258337                      else g qss
%o A258337 -- _Reinhard Zumkeller_, Jul 01 2015
%Y A258337 Cf. A000040, A018800, A030665, A062584, A258190, A258339.
%K A258337 nonn,base
%O A258337 1,1
%A A258337 _Vladimir Shevelev_, May 27 2015