Answers for "is prime number c#"

C#
0

is prime number c#

using System;
namespace Demo {
   class MyApplication {
      public static void Main() {
         int n = 5, a = 0;
         for (int i = 1; i <= n; i++) {
            if (n % i == 0) {
               a++;
            }
         }
         if (a == 2) {
            Console.WriteLine("{0} is a Prime Number", n);
         } else {
            Console.WriteLine("Not a Prime Number");
         }
         Console.ReadLine();
      }
   }
}
Posted by: Guest on August-03-2021

C# Answers by Framework

Browse Popular Code Answers by Language