Snippets

Tarık Kaya FiddlePrime

Created by Tarık Kaya
#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;
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.