hamzajaved

Print first N Prime Numbers

Oct 5th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. class Program
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.             int x, i,N;
  6.             Console.WriteLine("Enter the Value of N");
  7.             N = Convert.ToInt16(Console.ReadLine());
  8.             for (x = 1; x <= N; x++)
  9.             {
  10.                 for (i = 2; i < N; i++)
  11.                 {
  12.                     if (x % i == 0)
  13.                     {
  14.                         break;
  15.                     }
  16.                 }
  17.                 if(i == x)
  18.                 {
  19.                     Console.Write(i + "\t");
  20.                 }
  21.             }
  22.          
  23.            
  24.          
  25.         }
  26.     }
Add Comment
Please, Sign In to add comment