Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (25 sloc) 631 Bytes
#include <iostream>
using namespace std;
unsigned long long int superpermutationLength(int&);
int main(){
int digits;
cout << "Enter number of digits: ";
cin >> digits;
cout << "The minimum length of the superpermutation for " << digits << " digits is "
<< superpermutationLength(digits) << "." << endl;
return 0;
}
unsigned long long int superpermutationLength(int& digits){
int i;
int j;
unsigned long long int factorial;
unsigned long long int length = 0;
for (i = 1; i <= digits; i++){
factorial = 1;
for (j = 1; j <= i; j++){
factorial = factorial * j;
}
length += factorial;
}
return length;
}
You can’t perform that action at this time.