%mathpiper,def="SquareFreeDivisorsList"

/* Implementation of some number theoretical functions for MathPiper */
/* (C) 2002 Pablo De Napoli <pdenapo@yahoo.com> under GNU GPL */

/* Returns a list of the square-free divisors of n */
SquareFreeDivisorsList(n_IsPositiveInteger) <--
[
 Local(nFactors,f,result,oldresult,x);
 nFactors:= Factors(n);
 result := {1};
 ForEach (f,nFactors)
    [
      oldresult := result;
        ForEach (x,oldresult)
	  result:=Append(result,x*f[1]);
    ];
  result;
];

%/mathpiper



%mathpiper_docs,name="SquareFreeDivisorsList",categories="User Functions;Number Theory"
*CMD SquareFreeDivisorsList --- the list of square-free divisors
*STD
*CALL
	SquareFreeDivisorsList(n)
*PARMS

{n} -- positive integer

*DESC

{SquareFreeDivisorsList} creates a list of the square-free divisors of $n$.
Square-free numbers are numbers that have only simple prime factors (no prime powers).
For example, $18=2*3*3$ is not square-free because it contains a square of $3$ as a factor.

*E.G.

In> SquareFreeDivisorsList(18)
Result: {1,2,3,6};

*SEE DivisorsList
%/mathpiper_docs