1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#include <iostream> using namespace std; const int H = 240; const int W = 320; bool visited[H * W]; const int prime = 31; int main() { int at = 0; int numVisited = 0; while (!visited[at]) { visited[at] = true; numVisited++; // pixel coordinates to fiddle int x = at % W; int y = at / W; at += prime; at %= H * W; } cout << numVisited << " / " << H * W << endl; // OUTPUT: // 76800 / 76800 return 0; }
You can clone a snippet to your computer for local editing. Learn more.