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
Gomathi Palaniswamy
NA
3.5k
2.2m
prime no
Dec 7 2010 2:24 AM
Sir/Madam,
How to find the prime number between 2^511 and 2^512.I have tried the below code but its not giving proper output.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
bool prime = false;
Console.WriteLine((Math.Pow(2,511)).ToString());
Console.WriteLine((Math.Pow(2, 512)).ToString());
double a = Math.Pow(2, 511);
double b=Math.Pow(2, 512);
Console.WriteLine((b-a).ToString());
while (a < b)
{
for (double i = 2; i < 10; i++)
{
if (a % i == 0)
{
prime = true;
//Console.WriteLine(i.ToString());
break;
}
}
if (prime == false)
{
// Console.WriteLine(a.ToString());
break;
}
a = a + 1;
}
Console.ReadLine();
}
}
}
Thanks in advance...
Reply
Answers (
5
)
How to go about making a database that can be accessed by multiple computers?
Blank crystal report using typed dataset visual c# 2008