Advertisement
Guest User

Untitled

a guest
Jan 21st, 2015
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. static void Main(string[] args)
  2.         {
  3.             // Write an expression that checks if given positive integer number n (n = 100) is prime (i.e. it is divisible without remainder only to itself and 1).
  4.             int n = 0;
  5.             do
  6.             {
  7.                 Console.WriteLine("Input a positive integer:");
  8.                 n = int.Parse(Console.ReadLine());
  9.             }
  10.             while (n <= 1);
  11.             bool prime = true;
  12.            if ((n % n == 0) && (n % 1 == 0))
  13.  
  14.             {
  15.                 Console.WriteLine(prime);
  16.             }
  17.             else
  18.             {
  19.                 Console.WriteLine(!prime);
  20.             }
  21.  
  22.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement