%mathpiper,def="HarmonicNumber"

10 # 	HarmonicNumber(n_IsInteger)	<-- HarmonicNumber(n,1);
HarmonicNumber(n_IsInteger,r_IsPositiveInteger) <--
[
	// small speed up
	if( r=1 )[
		Sum(k,1,n,1/k);
	] else [
		Sum(k,1,n,1/k^r);
	];
];

%/mathpiper



%mathpiper_docs,name="HarmonicNumber",categories="User Functions;Number Theory"
*CMD HarmonicNumber --- return the {n}th Harmonic Number
*STD
*CALL
	HarmonicNumber(n)
	HarmonicNumber(n,r)
*PARMS

{n}, {r}	-- positive integers

*DESC

This function returns the {n}-th Harmonic number, which is defined
as $Sum(k,1,n,1/k)$. If given a second argument, the Harmonic number
of order $r$ is returned, which is defined as $Sum(k,1,n,k^(-r))$.

*E.G.

In> HarmonicNumber(10)
Result: 7381/2520;
In> HarmonicNumber(15)
Result: 1195757/360360;
In> HarmonicNumber(1)
Result: 1;
In> HarmonicNumber(4,3)
Result: 2035/1728;



*SEE Sum
%/mathpiper_docs