sieve

Finding composite numbers

I have a range of random numbers. The range is actually determined by the user but it will be up to 1000 integers. They are placed in this: vector<int> n and the values are inserted like this: srand(1); for (i = 0; i < n; i++) v[i] = rand() % n; I'm creating a separate function to find all the non-prime values. Here is what I...

Is there a way to find the approximate value of the nth prime?

Is there a function which will return the approximate value of the n th prime? I think this would be something like an approximate inverse prime counting function. For example, if I gave this function 25 it would return a number around 100, or if I gave this function 1000 it would return a number around 8000. I don't care if the number r...

How can I link against the PostgreSQL libs when I compile Cyrus's seiveshell?

I maintain a software stack consisting of Perl and Cyrus IMAP among other things. Perl seems to be working fine and Cyrus cyradm (a perl script) works fine too. However, sieveshell will not execute and reason for asking for help here. When I run sieveshell, I get the follow output: Can't load '/usr/local/pozix/perl-5.10.0/lib/site...

Haskell --> F#: Turner's Sieve

I was reading on different sieving algorithms when I stumbled upon a kind of improved version of the Sieve of Eratosthenes called Euler's Sieve. According to Wikipedia there is an implementation of an slightly different version of the idea (called Turner's Sieve) in Haskell. Now I am trying to understand what exactly the code snippet gi...

Good design pattern for running a process on a collection of data?

Best explained with code I think, this is just a simple example: public class MyPOJO { public String name; public int age; public MyPOJO(String name, int age) { this.name = name; this.age = age; } } public class MyProcessor { public List<MyPOJO> process(List<MyPOJO> mypojos) { List<MyPOJO>...