Which is the fastest algorithm to find prime numbers?
Which is the fastest algorithm to find out prime numbers using C++? I have used sieve’s algorithm but I still want it to be faster! 18 Answers 18
Which is the fastest algorithm to find out prime numbers using C++? I have used sieve’s algorithm but I still want it to be faster! 18 Answers 18
I have a line from A to B and a circle positioned at C with the radius R. What is a good algorithm to use to check whether the line intersects the circle? And at what coordinate along the circles edge it occurred? 29 Answers 29
I have a simple JavaScript Array object containing a few numbers. [267, 306, 108] Is there a function that would find the largest number in this array? 32 Answers 32 Resig to the rescue: Array.max = function( array ){ return Math.max.apply( Math, array ); }; Warning: since the maximum number of arguments is as low … Read more
How can I find (iterate over) ALL the cycles in a directed graph from/to a given node? For example, I want something like this: A->B->A A->B->C->A but not: B->C->B 17 Answers 17
I am looking for an algorithm to convert between HSL color to RGB. It seems to me that HSL is not very widely used so I am not having much luck searching for a converter. 22 Answers 22
How would I “inflate” a polygon? That is, I want to do something similar to this: The requirement is that the new (inflated) polygon’s edges/points are all at the same constant distance from the old (original) polygon’s (on the example picture they are not, since then it would have to use arcs for inflated vertices, … Read more
It’s trivial to write a function to determine the min/max value in an array, such as: /** * * @param chars * @return the max value in the array of chars */ private static int maxValue(char[] chars) { int max = chars[0]; for (int ktr = 0; ktr < chars.length; ktr++) { if (chars[ktr] > … Read more
I want to create a hash of I love cupcakes (signed with the key abcdeg) How can I create that hash, using Node.js Crypto? 4 Answers 4
Is there a programmatic way to detect whether or not you are on a big-endian or little-endian architecture? I need to be able to write code that will execute on an Intel or PPC system and use exactly the same code (i.e. no conditional compilation). 29 Answers 29
What are differences between segment trees, interval trees, binary indexed trees and range trees in terms of: Key idea/definition Applications Performance/order in higher dimensions/space consumption Please do not just give definitions. 3 Answers 3