/* Christopher D'Urso
* chris@durso.org
* for more information see
* http://www.durso.org/PerfectShuffling/Perfect_Shuffling.html
*
* June 7, 2002
* updated: 8/21/04
* Compute the period of perfect suffles for a series of sets of objects
* NOTE: This program will never end in "real time" UINT64*UINT64 is far
* to big a number! so just run as long as you wish or until your storage
* runs out!
*/
#include
#include
#include
int main(void){
FILE*f;
unsigned long long v; // position of element 1
unsigned long long n; // number of elements in set minus 1
f = fopen("./shuffles.bin_unsignedlonglong", "w");
assert(f);
for(n = 3; n < (UINT64_MAX/2LL - 1) ; n += 2){
unsigned long long count = 0;
v = 1;
do{
v = v*2LL % n ;
count++;
}while(1 != v);
/*
* completed one shuffling at position 1 again
* print the results
*/
fwrite(&count, sizeof(count), 1, f);
}
fclose(f);
return 1;
}