Advertisement
Guest User

Prime Numbers

a guest
Mar 12th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | None | 0 0
  1. using System;
  2.  
  3. class PrimeNumbers
  4. {
  5.     static void Main()
  6.     {
  7.         int number = int.Parse(Console.ReadLine());
  8.         int divByTwo = number / 2;
  9.         int divByThree = number / 3;
  10.         int divByFive = number / 5;
  11.         if (number > 0)
  12.         {
  13.             Console.WriteLine((number != 2 && number == divByTwo * 2) || (number != 3 && number == divByThree * 3) || (number != 5 && number == divByFive * 5) ? "The number is Prime!" : "The number is NOT Prime!");
  14.            
  15.         }
  16.         else Console.WriteLine("The number is not Prime!");
  17.         Main();
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement