patternprogram_199 softethics

Pattern 199 (Prime No.Pattern)

C

#include <stdio.h>

int main ()
{
  int n = 5;
  int i,j,k,r;
  int cn=1,count;

  for(i = 1; i <= n; i++)
  {
    for (j = 1; j <= n; j++)
    {
      for (k = cn + 1; k <= 10000; k++)
      {
        cn=k;
        count=0;
        for (r = 1; r <= cn; r++)
        {
          if(cn%r==0)
            count++;
        }
        if(count==2)
        {
          printf("%2d ",cn );
          break;
        }

      }

    }
    printf ("\n");
  }
  return 0;
}

C++

Java

C#

Python

5 2 votes
Rate this Program
Subscribe
Notify of
guest


0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments