<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>nPr, permutation</Title>
      <Shortcut>nPr,permutation</Shortcut>
      <Description>nPr, permutation [C#]</Description>
      <Author>yancyn Then</Author>
      <HelpUrl>/PreviewSnippet.aspx?SnippetID=025aa48f-e693-4c9c-9c7a-4b3eb4e0d4b7</HelpUrl>
      <SnippetTypes>
        <SnippetType>SurroundsWith</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Code Language="csharp"><![CDATA[/// <summary>
		/// Permutation.
		/// 
		/// <code>
		/// n			  n!
		///  P		= __________
		///    r		(n-r)!
		/// 
		/// n * (n-1) * (n-2) * (n-3) * ..... * (lower+1) * lower.
		/// </code>
		/// </summary>
		/// <param name="upper"></param>
		/// <param name="lower"></param>
		/// <returns></returns>
		private long nPr(long upper,long lower)
		{
			long output = 1;
			if(lower<1) lower = 1;			
			for(long i=upper;i>=lower;i--)
				output *= i;
			return output;
		}]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>