Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class PrimeNr
- {
- static void Main()
- {
- Console.Write("Enter a number from 2 to 100: ");
- int input;
- int remain=1;
- while ((!int.TryParse(Console.ReadLine(), out input)) || !(input <= 100 && input > 1))
- {
- Console.WriteLine("\nPlease enter a number from 2 to 100: ");
- }
- for (int i = 2; i < input; i++)
- {
- remain = input % i;
- if (remain == 0)
- {
- Console.WriteLine("\n{0} is composite number.\n",input);
- break;
- }
- }
- if (remain != 0)
- {
- Console.WriteLine("\n{0} is prime number.\n",input);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement