login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A097468 Number of 1's in the decimal expansion of the lesser of twin primes. 0

%I #8 Dec 24 2018 13:48:19

%S 0,0,2,1,0,1,0,1,2,1,1,1,1,2,1,0,0,0,1,2,0,1,1,1,1,0,0,1,1,0,0,1,0,0,

%T 1,2,2,1,2,2,3,1,1,1,2,2,1,2,2,1,1,2,1,1,2,1,2,1,2,1,1,0,1,0,3,1,2,0,

%U 0,0,0,1,0,1,0,0,2,0,0,1,0,0,2,1,1,0,0,0,0,1,0,1,0,0,0,0,1,1,0,1,1,1,0,1,1

%N Number of 1's in the decimal expansion of the lesser of twin primes.

%C n=5000,d=1 in PARI code below.

%e 11 is the third lesser twin prime so 2 is the third entry

%t DigitCount[#,10,1]&/@(Select[Partition[Prime[Range[1000]],2,1], #[[2]] - #[[1]] == 2&][[All,1]]) (* _Harvey P. Dale_, Dec 24 2018 *)

%o (PARI) g(n,d) = forprime(x=1,n,if(isprime(x+2),print1(countchr(x,d)","))) \Count the occurrences of char in string str countchr(str,char) = { local(ln,x,c); str=Str(str); \This allows leaving quotes off input char=Str(char); c=0; ln=length(str); for(x=1,ln, if(mid(str,x,1)==char,c++); ); return(c) } \ Get a substring of length n from string str starting at position s in str. mid(str,s,n) = { local(v,ln,x,tmp); v =""; tmp = Vec(str); ln=length(tmp); for(x=s,s+n-1, v=concat(v,tmp[x]); ); return(v) }

%K base,nonn

%O 2,3

%A _Cino Hilliard_, Aug 23 2004

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 29 09:35 EDT 2024. Contains 375511 sequences. (Running on oeis4.)