Please anyone tell me coding to print prime numbers from 1 to
5000 in c#....
Answers were Sorted based on User's Feedback
Answer / slau
In PHP, translate C# yourself
//array for prime numbers
$primes=array(2); //speed trick - we know that 2 is prime
for ($i=3;$i<=5000;$i+=2) { //speed - check only odd numbers
//max. possible divisor for number
$maxdiv = sqrt($i);
for ($j=0; $j<count($primes); $j++) {
// if modulus = 0, number has divisor
if (0 == $i % $primes[$j]) {
break;
}
//if all possible prime divisors checked, add new prime
if ($primes[$j] > $maxdiv) {
$primes[] = $i;
echo "$i\n";
break;
}
}
}
not very brilliant, 10 mins for coding, but runs pretty fast
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / guest
int i=0;
for(i=0;i<=5000;i++)
console.writeline(i);
| Is This Answer Correct ? | 1 Yes | 8 No |
5. Which of the following can you do with DB2 Express- C? Query databases with SQL Query databases with XML using XQuery and XPath Use SQL in Xquery and Xquery in SQL All of the above
qtp 9.2 14 days demo version was expired.I uninstalled how to reinstall this again
What are two of your strengths that you will bring to our QA/testing team?
For a binary tree with n nodes, How many nodes are there which has got both a parent and a child?
To sorting array of 10 elements which sorting is best a)selection b)bubble c)tree sort
What's the difference b/w Table & Templete in Smartform?
how to avoid java script validation in client side validation?
difference between mantis and other tools?
Given a arbitrary pointer to an element in a singly linked list?what is the time complexity for its deletion .
what is delegate and delegation model give the real live example on delegate model
how many logical drive we can form to physical device in our computer?
Given: coordinates of rectangle-> left bottom and right top points. the rectangles create a hole.Find the maximum area of the hole. eg. 4 rectangles create a hole in between. find its area.