Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.33 KB | None | 0 0
  1. using System;
  2.  
  3. class Example
  4. {
  5.     public static void Main ()
  6.     {
  7.         int n = int.Parse (Console.ReadLine ());
  8.         bool isPrime = true;
  9.  
  10.         if (n <= 1)
  11.         {
  12.             isPrime = false;
  13.         }
  14.  
  15.         for (int i = 2; i <= n; i++)
  16.         {
  17.             if (n % i == 0)
  18.             {
  19.                 isPrime = false;
  20.                 break;
  21.             }
  22.         }
  23.  
  24.         Console.WriteLine (isPrime ? "Prime" : "Not Prime!");
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement