SHARE
TWEET

C# Part 1 / Operators and Expressions / 07. PrimeNumber

BackoChan Nov 8th, 2013 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. class PrimeNumber
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("Enter number  below 100 :");
  8.         int primeNumber = int.Parse(Console.ReadLine());
  9.         if (primeNumber <= 100)
  10.         {
  11.             if ((primeNumber % primeNumber == 0 && primeNumber % 1 == 0 && primeNumber % 2 != 0 && primeNumber % 3 != 0 && primeNumber % 5 != 0)
  12.                 || ((primeNumber == 2) || (primeNumber == 3) || (primeNumber == 5)))
  13.             {
  14.                 Console.WriteLine("The number is prime");
  15.             }
  16.             else
  17.             {
  18.                 Console.WriteLine("not prime");
  19.             }
  20.         }
  21.         else
  22.         {
  23.             Console.WriteLine("invalid number");
  24.         }
  25.        
  26.     }  
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top