python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
prime number program using c#.net

Prime number program using ASP.Net C#

A prime number can be divided only by itself or by 1 that number is called prime number.

For Example : The number 3 can be divided only by 3 or by 1 that means we say that the number 3 is a prime member.

Noted point:  The number 0 and 1 are not considered prime numbers.

Prime Numbers : 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61..

The live demo example link using JavaScript https://jsfiddle.net/xfpe35tb/

I am going to share the example using Asp.Net C# as given below.

class PrimeNumber
{
    static void Main(string[] args)
    {
        bool IsPrimeNum = true;
        Console.WriteLine("Please enter numbers for get prime number. ");
        long number = Convert.ToInt32(Console.ReadLine());

        for (long p = 2; p <= number; p++)
        {
            for (long q = 2; q <= number; q++)
            {
                if (p != q && p % q == 0)
                {
                    IsPrimeNum = false;
                    break;
                }

            }
            if (IsPrimeNum)
            {
                Console.WriteLine(p);
            }
            IsPrimeNum = true;
        }
        Console.ReadLine();
    }

}

Live output as given below



ANIL SINGH

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions