Home   Log in   register   Contact Us   License   Links
Episodes   Shippuuden   Manga   Movies   OVA   Games   Gallery   Cosplay   Toys   Store   Top Sites


My Simple Prime Detector

November 23, 2009 | Posted in Other Interests, Information Technology, Computer and Internet

I’ve just made a C# Console Application code for detecting prime numbers. This only shows if the input number is a prime or not a prime. It is just simple but maybe it may help you.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace Prime

{

    class Program

    {

        static void Main(string[] args)

        {

            int num;

            Console.Write("Enter Number:");

            num = Convert.ToInt32(Console.ReadLine());

            int i;

            for(i = 2; i < num; i++)

            {

            if (num % i == 0)

            {

            Console.WriteLine("is not a prime");

            break;

            }

            }

            if(i==num)

            {

            Console.Write("is a prime");

            }

            Console.ReadLine();

            }

        }

    }

if you have any questions, please.. Feel free to leave a comment. Thank you

 

 


Bookmark and Share

|




Comments »

No comments yet.

RSS feed for comments on this post.


Leave a comment



Anti-spam measure: please retype the above text into the box provided.