Good day! I am having some trouble with my permutation calculator. For some reason, the end result is always 1. We are not allowed to use recursion at the moment so I opted to use a for loop for finding the factorials.
Here is my code:
#include <iostream>
using namespace std;
int fact(int x);
int perm(int y, int z);
int n, r, npr;
char ch;
int main()
{
    do{
        cout<<"Enter n (object/s): ";
        cin>> n;
        cout<< "Enter r (sample/s): ";
        cin>> r;
        npr= perm(n,r);
        cout<< "Value of "<< n<<"P"<< r<< " = "<< npr<<endl;
        cout<<"Would you like to repeat this again? [y/n] \n";
        cin>> ch;
        cout<< "\n";
    } while(ch=='y');
    cout<< "Thank you and have a nice day!";
    return 0;
}
int fact(int x)
{
   int number, cum = 1;
    for(number=1;number<=n;number++)
      cum=cum*number;
    return cum;
}
int perm(int y, int z)
{
    return fact(n) / fact(n-r);
}
 
    