Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class PrimeNumberCheck
- {
- static void Main()
- {
- while (true)
- {
- Console.Write("Въведи цяло положително число [1..120]: ");
- int num = int.Parse(Console.ReadLine());
- while (num < 0 || num > 120)
- {
- Console.Write("Въведи цяло положително число [1..120]: ");
- num = int.Parse(Console.ReadLine());
- }
- if (num == 2 || num == 3 || num == 5 || num == 7)
- {
- Console.WriteLine(num + " e просто число.");
- }
- else if ((num == 0) || (num == 1))
- {
- Console.WriteLine(num + " не е нито просто, нито съставно.");
- }
- else if (num < 0)
- {
- }
- else if (num % 2 != 0 && num % 3 != 0 && num % 5 != 0 && num % 7 != 0)
- {
- Console.WriteLine(num + " е просто число.");
- }
- else
- {
- Console.WriteLine(num + " е съставно число.");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement