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

 


The integers sieved by 7, 5, 3, and 2.
0

%I #32 Dec 15 2023 18:11:01

%S 7,1,2,3,2,5,3,7,2,3,5,1,3,1,7,5,2,1,3,1,5,7,2,1,3,5,2,3,7,1,5,1,2,3,

%T 2,7,3,1,2,3,5,1,7,1,2,5,2,1,3,7,5,3,2,1,3,5,7,3,2,1,5,1,2,7,2,5,3,1,

%U 2,3,7,1,3,1,2,5,2,7,3,1,5,3,2,1,7,5,2

%N The integers sieved by 7, 5, 3, and 2.

%C A number is tested for the following in order - the first test passed determines a(n):

%C Is n mod 7 == 1? If so, write 7.

%C Is n mod 5 == 1? If so, write 5.

%C Is n mod 3 == 1? If so, write 3.

%C Is n mod 2 == 1? If so, write 2.

%C Write 1.

%C Period 210. - _Charles R Greathouse IV_, Sep 22 2012

%C An example of an inverted sieve. Usually we would sieve 2, 3, 5, 7 which gives 2, 1, 2, 3, 2, 5, 2, 7, 2, 3, 2, 1. - _Jon Perry_, Sep 24 2012

%e 4 is not 1 mod 7 or 1 mod 5 but is 1 mod 3, so a(4) = 3.

%t Table[If[Mod[n, 7] == 1, 7, If[Mod[n, 5] == 1, 5, If[Mod[n, 3] == 1, 3, If[Mod[n, 2] == 1, 2, 1]]]], {n, 100}] (* _T. D. Noe_, Sep 25 2012 *)

%t Table[Which[Mod[n,7]==1,7,Mod[n,5]==1,5,Mod[n,3]==1,3,Mod[n,2]==1,2,True,1],{n,90}] (* _Harvey P. Dale_, Mar 04 2016 *)

%o (JavaScript) for (i=1;i<90;i++)

%o if (i%7==1) document.write("7,");

%o else if (i%5==1) document.write("5,");

%o else if (i%3==1) document.write("3,");

%o else if (i%2==1) document.write("2,");

%o else document.write("1,");

%o (C++)

%o template <typename T> std::string PrintSequnce_A216983(const T &max)

%o {

%o std::string strSeq;

%o for(T i = 1; i < max; ++i)

%o {

%o if (i%7==1) strSeq+="7";

%o else if (i%5==1) strSeq+="5";

%o else if (i%3==1) strSeq+="3";

%o else if (i%2==1) strSeq+="2";

%o else strSeq+="1";

%o if(i<max-1)

%o strSeq+=", ";

%o }

%o return strSeq;

%o } // _Martin Ettl_, Oct 08 2012

%K nonn,easy

%O 1,1

%A _Jon Perry_, Sep 21 2012

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | 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 September 20 23:55 EDT 2024. Contains 376078 sequences. (Running on oeis4.)