|
I want to print the first 10000 prime numbers. Can anyone give me the most efficient code for this? Clarifications:
It does not matter if your code is inefficient for n >10000. The size of the code does not matter. You cannot just hard code the values...
Started by Niyaz on
, 19 posts
by 18 people.
Answer Snippets (Read the full thread at stackoverflow):
/^1 adapted code found on the CodeProject to create the following:
ArrayList primeNumbers = new on an ancient Pentium II-350
Sieve of Eratosthenes....
Not efficient at all, but you can use a regular expression to test for prime numbers.
|
|
I have an ASP.NET (C#) class that is used both on the client and server.
Depending on whether the code is being executed on the client or the server, it needs to behave differently.
What is the simplest & most efficient way of telling if the code is executing...
Started by Shaul on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
By your tags I see.
Unless you are running Silverlight 2 or Silverlight 3 There is no way for Asp.Net to run C# code: C# code is always executed on the server, JavaScript is executed on the client.
|
|
As all of you may know, Java code is compiled and interpreted by JVMs. My questions deal with optimization: Is it optimized at run-time by the JVM only or also at compile-time?
In order to write efficient code, where can I find the list of supported optimizations...
Started by dilig0 on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Have performance goals The Java HotSpot JIT compiler can detect... .
I'd definitely choose writing code for readability and maintainability over supposed optimisations, not just Java):
Write code that is as readable and maintainable as possible.
|
Ask your Facebook Friends
|
Hi all, I'm trying to write more readable and more efficient code, I've always hated if if if chains .. is it possible to write the following statement in some other more "elegant" way like maybe using ternary ops :
if(text.length < 1){ if(errtext....
Started by Gandalf StormCrow on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
(Not that it matters in the context you're they're more clear to a reader... .
You could throw in a ternary (I'm assuming, but with a non-optimising compiler it's also less efficient.
Cannot be empty"; }
Your code as quoted seems quite clear.
|
|
In a typical handheld/portable embedded system device Battery life is a major concern in design of H/W, S/W and the features the device can support. From the Software programming perspective, one is aware of MIPS, Memory(Data and Program) optimized code...
Started by goldenmean on
, 15 posts
by 15 people.
Answer Snippets (Read the full thread at stackoverflow):
Especially the event timer you may be tempted updating window content, ensure your code recreates as little of the invalid region as possible With quick code the CPU goes back to....
Haven't checked for "sleep and spin" kind of code.
|
|
I have been looking around online and I cant seem to find an article on this that isn't totally outdated. Does anyone have any good articles that give some good advice? What I have read so far is good, and a bit helpful, but I want to have modern code...
Started by Chris B. on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Here's a link to show ....
It promotes reuse and makes code a lot more readable.
Edit for the Question Edit Clean and efficient already, I suggest making your PHP code object-oriented.
Use Smarty
Write to patterns as much as possible.
|
|
This could sound a subjective question, but what i am looking for is specific instances which you would have encountered related to this.
1) How to make a code, cache effective-cache friendly? (More cache hits, as less cahce misses as possible). from ...
Started by goldenmean on
, 13 posts
by 13 people.
Answer Snippets (Read the full thread at stackoverflow):
Similarly, algorithms which access contiguous memory blocks will be more efficient than algorithms which jump through memory in a random order to guarantee that a data structure that....
Within a single cache-line are therefore more efficient.
|
|
If(strpos($string, "PENIS") != false){ echo 'This word is not allowed'; } if(strpos($string, "VAGINA") != false){ echo 'This word is not allowed'; }
Okay, so I am trying to check the submit data to see if there are inappropriate words. Instead of making...
Started by Doug on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
You really want !==, since strpos() will return 0 if the first .
Question-code, you test strpos != false.
|
|
Let me preface by saying I am not knocking .Net (it helps me earn my living)...
I recently heard of a site were the developer/owner bragged that he had minimal hardware to support his site (plentyoffish.com). This site is listed as being in the top 50...
Started by Miyagi Coder on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Way more performance than just picking a fast langauge and writing code that isn't tuned of maintaining the code is also important....
What else is there? PHP? Java? Ruby? Sure you could code up your web.
Is actually quite efficient.
|
|
I am currently writing code in C++ to find all possible permutations of 6 integers and store the best permutation (i.e. the one whose total is closest to a given value).
I am trying to write this code as efficiently as possible and would apreciate any...
Answer Snippets (Read the full thread at stackoverflow):
But it's certainly the most efficient in programmer.
It has full code and was written by a fellow SO'r , it should be enough to get to examine the array to work out what to change.
And Permutations in Code .
|