Prime number or not program in swift basic programs

Prime number or not program in swift programming language. This is the basic set of program in every programming language swift basics. To print the prime number or not in swift. There are two different set of loops were used to print the output. If else function prints the output only it satisfies the condition only.

var value=0
var n = 10
var i = 2
for i in 2 ... n-1
{
   if(n%i==0)
   {
       value = 1;
       break;
   }
}
if(value==1)
{
    print("\(n)" + " not prime")
}
else
{
    print("\(n)" + "  prime")
}
Output:

10 is not prime