Write a program in C# which asks the user for an integer number and answers if it is a prime number or not.
public class PrimeNumber
public static void Main(string args)
int x = Convert.ToInt32(Console.ReadLine());
int divider = 2;
while (x % divider != 0)
if (divider == x)
Console.WriteLine("Is not prime");
Practice C# anywhere with the free app for Android devices.
Learn C# at your own pace, the exercises are ordered by difficulty.
Your donations support our work and contribute to the maintenance of the app.
Own and third party cookies to improve our services. If you go on surfing, we will consider you accepting its use.