Some time ago a bunch of guys here recommended me Haskell as my first functional language.
I've read some tutorials and followed the advice of one guy to try to solve the problems in
Project Euler to get some pratice.
I have solved a couple of problems and found Haskell to be really cool to this sort of math programming, but I have found one that seems an inherently imperative problem.
Quote:By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6^(th) prime is 13.
What is the 10001^(st) prime number?
without optimizing too much, this seems fairly easy in c (assuming number doesn't overflows, about which I can't be sure):
int i = 0;
long long number = 2;
while (i < 10001)
{
if (isPrime(number++))
i++;
}
Now I'm very puzzled about how to solve this in Haskell.
I think we can make a recursive list requiring that each element is strictly greater than the previous one and that each element is prime.
Is this the functional way to do this? Any better approach?
I don't want the solution, just a theoretical discussion about the functional way to do this sort of things.