Program to check whether a number is prime or not in C# Console – Programming, Pseudocode Example, C# Programming Example
C# Console

Program to check whether a number is prime or not in C# Console

Example to check whether an integer (entered by the user) is a prime number or not using for loop and if…else statement.

A positive integer which is only divisible by 1 and itself is known as prime number.

For example: 17 is a prime number because it is only divisible by 1 and 17 but, 10 is not prime number because it is divisible by 1, 2, 5 and 10.

C# Code:

 

Output:

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.