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 |
Question:Why is mapping required? Computer 'Paging' & 'Segmentation'. Question:Give the disadvantages of Havander's Strategies. Question: What do you mean by Belady's Anomaly. - Describe with example. Question: Discuss the various function of OS. Question: Give a brief discussion on schedulers & Dispatchers with respect to process management.
What is meant by spooling
Colors specified with the notation
how pseudo column works?
How to set on/off a group of indicators in a single statement?
Compare any 4 software development life cycle paradigms with each other. Indicate at least one application for each of the paradigms that are suitable to developed using that paradigm.
6.int x=10; float y=20; a=x%2=? b=y%2=?
A string of charaters were given. Find the highest occurance of a character and display that character. eg.: INPUT: AEGBCNAVNEETGUPTAEDAGPE
What is the difference between compiled and interpreted languages?
can we extend a class having only one parameterised constructor.Suggest the process to do it.
What is test execution and when will we start execution please send me one example for this question
code for connection from windows forms to sql server