/* calcperm e.g calcperm 1 7 1000000 26 Total permutations = 8353082582 000:02:139:13 */ #include #include #include #include void main(int argc, char *argv[]) { int minLen,maxLen,charlen,i; int keysPs; double totalKeys=0.0; int days,hours,minutes,seconds; if(--argc == 4) { minLen = atoi(argv[1]); maxLen = atoi(argv[2]); keysPs = atoi(argv[3]); charlen = atoi(argv[4]); for(i=minLen;i<=maxLen;i++) totalKeys += pow((double)charlen,(double)i); printf("\nTotal permutations = %0.f",totalKeys); seconds = totalKeys/keysPs; minutes = seconds/60; hours = minutes/60; days = hours/24; printf("\n%03d:%02d:%02d:%02d\n",days,hours,minutes,seconds%60); } }