# Prime number - Practice Exercises C# Sharp

## Lesson 2:

## Flow Control

## Exercise 2.32:

## Prime number

## Objetive:

## Write a program which asks the user for an integer number and answers if it is a prime number or not.

## Source Code:

```
using System;
public class Prime
{
public static void Main()
{
int number;
int dividers = 0;
Console.Write("Enter a number: ");
number = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i <= number; i++)
if (number % i == 0)
dividers++;
if (dividers == 2)
Console.WriteLine("The number is prime");
else
Console.WriteLine("The number is not prime");
}
}
```

Exercisey
2.32