1
$\begingroup$

Program should return a list of all the divisors of n!-1 for n=50,51,...,59 using parallel computing.

Here is my current solution:

 Parallelize[
   DeleteDuplicates[
     Flatten[Table[Divisors[n! - 1], {n, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}]]]]

but it doesn't work. I don't know how to handle:

"Parallelize::nopar1: DeleteDuplicates[Flatten[Table[Divisors[n!-1],{n,50,51,52,53,54,55,56,57,58,59}]]] cannot be parallelized; proceeding with sequential evaluation."

$\endgroup$
  • 4
    $\begingroup$ Seemingly altering to this form can solve the problem: DeleteDuplicates@Flatten@ParallelTable[Divisors[n! - 1], {n, Range[50,100]}] $\endgroup$ – Wjx Jun 12 '16 at 23:18
  • 1
    $\begingroup$ I suspect that this is because DeleteDuplicates needs to see the whole list to do its job: its operation cannot conceptually be parallelized. Table, on the other hand, can be handily parallellized. In other words, the Parallelize algorithms are not smart enough to identify this issue, so they give up. Generally speaking, however, parallelizing code is a difficulty task even for humans, and I can't fault the algorithm. As a hint, those commands for which a Parallel* version exists (e.g. ParallelTable) are the easiest to parallelize, so you should try to use those preferentially. $\endgroup$ – MarcoB Jun 12 '16 at 23:50
  • 1
    $\begingroup$ Replace {n, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59} with {n, {50, 51, 52, 53, 54, 55, 56, 57, 58, 59}} $\endgroup$ – xyz Jun 13 '16 at 2:04

Browse other questions tagged or ask your own question.