Tuesday, 6 August 2024

Prime No

other than 1,2,3 ,

6n+1 or 6n-1 will be prime no


for (int no= 5;no <= 100;no++)

{

    //int no = 6;

    int r1 = (no + 1) % 6;

    int r2 = (no - 1) % 6;


    if (r1 == 0 || r2 == 0)

    {

        Console.WriteLine(no + " is Prime Number");

    }

}

No comments:

Post a Comment