Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PrimeNumbers
- {
- class PrimeNumbers
- {
- static void Main()
- {
- int num;
- Console.WriteLine("Enter number: ");
- num = int.Parse(Console.ReadLine());
- if (num == 0 || num == 1)
- {
- Console.WriteLine(num + " is not a prime number");
- Console.ReadLine();
- }
- else
- {
- for (int a = 2; a <= Math.Sqrt(num); a++)
- {
- if (num % a == 0)
- {
- Console.WriteLine(num + " is not a prime number");
- return;
- }
- }
- Console.WriteLine(num + " is a prime number");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment