TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aditya Varma Mudunuri
NA
58
104.5k
Check the Number is Prime or Not
Mar 14 2014 9:06 AM
Please Check the following code i am facing an error in this code below
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Prime2
{
class CheckPrime
{
//Return true If x is Prime
#region IsPrimebooleanLogic
public bool IsPrime(int x)
{
for (int i = 2; i <= x / i; i++)
{
if ((x % i) == 0)
{
return false;
}
else
return true;
}
}
#endregion
}
class CheckPrimeDemo
{
static void Main(string[] args)
{
CheckPrime opt = new CheckPrime();
int end;
Console.WriteLine("Enter the Ending Number for Prime number search");
end = int.Parse(Console.ReadLine());
for (int i = 1; i < 10; i++)
{
if (opt.IsPrime(i))
Console.WriteLine(i+ " is Prime Number");
else
Console.WriteLine(i + " is Not Prime Number");
}
}
}
}
Reply
Answers (
1
)
How To show Twitter Tweets on asp.net c# Website...?
pop up on asp.net