SHARE
TWEET

Prime or Not

Martichka Nov 27th, 2012 38 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. class IsPrimeNumber
  3. {
  4.     static void Main()
  5.     {
  6.         Console.Write("Enter positive integer number n<=100: ");
  7.         int num = int.Parse(Console.ReadLine());
  8.         int prime = 0;
  9.         if ((num < 0) || (num > 100))
  10.         {
  11.             Console.WriteLine("You have entered invaled number.");
  12.         }
  13.         for (int check = 2; check < num; check++);
  14.         {
  15.             if (num % check == 0)
  16.             {
  17.                 prime = prime + 1;
  18.                 Console.WriteLine("not prime");
  19.             }
  20.  
  21.             else
  22.             {
  23.                 Console.WriteLine("prime");
  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