Prime Number Checker
Develop a C# function to check whether a given number n is a prime number. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
I completed my post-graduation in 2013 in the engineering field. Engineering is the application of science and math to solve problems. Engineers figure out how things work and find practical uses for scientific discoveries. Scientists and inventors often get the credit for innovations that advance the human condition, but it is engineers who are instrumental in making those innovations available to the world. I love pet animals such as dogs, cats, etc.
Ashutosh Kumar Verma
13-Jun-2024Prime Number Checker in C#
Below is a simple implementation of a prime number checker in C#,
Example-
In the above example-
number
.IsPrime
function to check if the input number is prime.IsPrime
function checks if the number is less than 2 and returns false if it is, because 0 and 1 are not prime numbers.Output- 1
Output- 2
This function must carefully check whether the given quantity is prime or not.
Also, Read: Fibonacci Sequence