hamzajaved

Check Weather the Number is Prime or Not

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