Complexity of the conjecture functions is O(n^4) and you're surprised it's quickly slow? If you want to multiply the upper limit by 2, you multiply the time needed by 8.
Multiply it by 10 and the time needed is multiplied by 10000
That's normal... You have to write it completely differently, even a supercomputer will struggle quite fast (the limit depend on the power, but it will never be high)
The correct way to do this:
- compute ONCE all primes up to N using Eratosthene sieve
- keep BOTH a table containing primes and the table containing TRUE/FALSE values needed in the sieve
- to check whether x is the sum of two primes, take all primes p before x/2 (by using the first table) and check whether x-p is prime (by checking the TRUE/FALSE value in the second time at position x-p)
Eratosthene is O(n log(log
)), so it will be bazing fast to compute all primes
Testing all values will still be slow, at O(n^2), but nowhere as slow... (for an upper bound of 1000, for example, the speed will be x1000000)
Edit: at the very least, you should be looking for divisors in isprime when i*i <= number and not i <= (number / 2), but that's a menial gain compared to other things...
Are those integers or real numbers?
As said, there's a bunch of different solution, depending on how well you want to be able to identify bad formatted files.
But if the file is properly formated, you can simply read digits, commas and ignore everything else...