Hello, I am asking for a hint.
For example, I have a list of random natural numbers:
t = Table[RandomInteger[{1, 10000}], {10^7}];
I want to count how many prime numbers there are:
howmany = 0;
Do[ If[ PrimeQ[ t[[i]] ], howmany++], {i, 10^7}]
and now the same but using parallel computation:
howmany = 0;
ParallelDo[ If[ PrimeQ[ t[[i]] ], howmany++], {i, 10^7}]
Unfortunately, the second result is incorrect. My guess is that because there is a problem with accessing vvv at the same time.
Is there any simple solution to this problem? E.g. Each thread has its cold number, and then at the end you can sum them up?
Pozdrawiam
M