title: Permutation and Combination c++ logical error
body: <p>This is my assignment, i finished writing my code  and it does compile but it is not giving the right answer. So i know there is some logical error but i cannot find out what.</p>
  
  <p>Plz check and tell me, simple code to calculate permutations and combinations</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int factorial(int n)
  {
      if (n == 0 or n == 1)
      {
          return 1;
      }
      else
      {
          return n * factorial(n - 1);
      }
  }
  int permutation(int a, int b)
  {
      //factorial(a);
  
      int perm = factorial(a) / factorial(a - b);
  
      return perm;
  }
  int combination(int a, int b)
  {
      int permutation(int a, int b);
      int factorial(int n);
  
      return permutation(a, b) / factorial(b);;
  }
  
  int main()
  {
      int n;
      int r;
  
      cout &lt;&lt; "Enter n: " &lt;&lt; endl;
      cin &gt;&gt; n;
      cout &lt;&lt; "Enter r: " &lt;&lt; endl;
      cin &gt;&gt; r;
  
  
  
      int factorial(int n);
      int permutation(int n, int r);
      int combination(int n, int r);
  
      if (n &gt;= r)
      {
  
          cout &lt;&lt; "Permutuation: " &lt;&lt; permutation &lt;&lt; endl;
          cout &lt;&lt; "Combination: " &lt;&lt; combination &lt;&lt; endl;
  
      }
      else
      {
          cout &lt;&lt; "Invalid" &lt;&lt; endl;
      }
      return 0;
  }
  </code></pre>
  
  <p>The answer given by the console </p>
  
  <pre><code>Enter n:
  6
  Enter r:
  5
  Permutuation: 00AC1375
  Combination: 00AC133E
  </code></pre>