how to check if a number is prime or not c#
if (intNumber % 2 == 0)
{
// this number is prime
}
else
{
// this number is not prime
}
how to check if a number is prime or not c#
if (intNumber % 2 == 0)
{
// this number is prime
}
else
{
// this number is not prime
}
how to check prime number in c#
using System;
public class PrimeNumberExample
{
public static void Main(string[] args)
{
int n, i, m=0, flag=0;
Console.Write("Enter the Number to check Prime: ");
n = int.Parse(Console.ReadLine());
m=n/2;
for(i = 2; i <= m; i++)
{
if(n % i == 0)
{
Console.Write("Number is not Prime.");
flag=1;
break;
}
}
if (flag==0)
Console.Write("Number is Prime.");
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us