How the above implementation of RelativePrimes works
Lets consider what it does to compute RelativePrimes[42].
Part[FactorInteger[42],All,1] returns a list of prime factors of (42) which is {2.3.7}.
Then the pure function (Range[#,41,#]&) is mapped over the list {2, 3, 7}. This is computed as (lst1) in the next cell.. The #& notation is explained in the discussion of Slot and SlotSequence.
Then (lst2) is simply a list of integers from 2 to 41 which is the output of
the next cell.
Then the list of relative divisors is returned by effectively evaluating the
next cell.
What Fold does in the previous cell is explicitly spelled out in the next
cell.
This implementation is elegant and runs efficiently in Mathematica, but I
think the code is much more difficult to understand, so it's harder to
maintain.
Created by Mathematica (May 17, 2004)