login
Circular primes that are not repunits.
13

%I #36 Aug 11 2024 14:41:34

%S 2,3,5,7,13,17,31,37,71,73,79,97,113,131,197,199,311,337,373,719,733,

%T 919,971,991,1193,1931,3119,3779,7793,7937,9311,9377,11939,19391,

%U 19937,37199,39119,71993,91193,93719,93911,99371,193939,199933,319993,331999,391939

%N Circular primes that are not repunits.

%C Relative complement of A004022 in A068652.

%C Conjecture: The sequence is finite.

%C From _Michael De Vlieger_, Dec 30 2017: (Start)

%C Primes > 5 in this sequence must only have digits that are in the reduced residue system modulo 10, i.e., {1, 3, 7, 9}.

%C There are 54 terms that have 6 or fewer decimal digits, the largest of which is 999331.

%C a(55) must be larger than 10^11. (End) [Corrected by _Felix Fröhlich_, Mar 15 + 24 2019]

%C From _Felix Fröhlich_, Mar 16 2019: (Start)

%C a(55) > 10^23 if it exists (cf. De Geest link).

%C Numbers k such that A262988(k) = A055642(k). (End)

%H Felix Fröhlich, <a href="/A293663/b293663.txt">Table of n, a(n) for n = 1..54</a>

%H P. De Geest, <a href="https://www.worldofnumbers.com/circular.htm">Circular Primes</a>

%e The numbers resulting from cyclic permutations of the digits of 1193 are 1931, 9311 and 3119, respectively and all those numbers are prime, so 1193, 1931, 3119 and 9311 are terms of the sequence.

%t Select[Prime@ Range[10^5], Function[w, And[AllTrue[Array[FromDigits@ RotateRight[w, #] &, Length@ w - 1], PrimeQ], Union@ w != {1} ]]@ IntegerDigits@ # &] (* or *)

%t Select[Flatten@ Array[FromDigits /@ Most@ Rest@ Tuples[{1, 3, 7, 9}, #] &, 9, 2], Function[w, And[AllTrue[Array[FromDigits@ RotateRight[w, #] &, Length@ w], PrimeQ], Union@ w != {1} ]]@ IntegerDigits@ # &] (* _Michael De Vlieger_, Dec 30 2017 *)

%o (PARI) eva(n) = subst(Pol(n), x, 10)

%o rot(n) = if(#Str(n)==1, v=vector(1), v=vector(#n-1)); for(i=2, #n, v[i-1]=n[i]); u=vector(#n); for(i=1, #n, u[i]=n[i]); v=concat(v, u[1]); v

%o is_circularprime(p) = my(d=digits(p), r=rot(d)); if(vecmin(d)==0, return(0), while(1, if(!ispseudoprime(eva(r)), return(0)); r=rot(r); if(r==d, return(1))))

%o forprime(p=1, , if(vecmax(digits(p)) > 1, if(is_circularprime(p), print1(p, ", "))))

%o (PARI) /* The following is a much faster program that only tests numbers whose decimal expansion consists of digits from the set {1, 3, 7, 9}. */

%o eva(n) = subst(Pol(n), x, 10)

%o next_v(vec) = my(k=#vec); if(vecmin(vec)==9, vec=concat(vector(#vec, t, 1), [3]); return(vec)); while(k > 0, if(vec[k]==9, vec[k]=1, if(vec[k]==3, vec[k]=7; return(vec), vec[k]=vec[k]+2, return(vec))); k--)

%o rot(n) = if(#Str(n)==1, v=vector(1), v=vector(#n-1)); for(i=2, #n, v[i-1]=n[i]); u=vector(#n); for(i=1, #n, u[i]=n[i]); v=concat(v, u[1]); v

%o search(n) = my(d=digits(n), e=[], ed=0); while(1, e=rot(d); while(1, if(!ispseudoprime(eva(e)), break, e=rot(e); if(e==d && ispseudoprime(eva(e)), print1(eva(d), ", "); break))); d=next_v(d))

%o searchfrom(n) = if(n < 12, forprime(p=n, 10, print1(p, ", ")); search(13), my(d=digits(n)); for(k=1, #d, if(d[k]%2==0, d[k]++, if(d[k]==5, d[k]=7))); search(eva(d)))

%o /* Start a search from 1 upwards as follows: */

%o searchfrom(1) \\ _Felix Fröhlich_, Mar 23 2019

%Y Cf. A004022, A055642, A068652, A262988, A293142.

%Y Cf. base-b nonrepunit circular primes: A293657 (b=4), A293658 (b=5), A293659 (b=6), A293660 (b=7), A293661 (b=8), A293662 (b=9).

%K nonn,base

%O 1,1

%A _Felix Fröhlich_, Dec 30 2017