/*******************************************************
 * Puzzle solution by Josh Falk 
 * (with a few clarity edits by Keith)
 */
#include <iostream>
using namespace std;

typedef void (*FunctionType)(int, int);
FunctionType functionPointers[2];

void PrintStartToEnd(int start, int end)
{
	cout << start << endl;
	functionPointers[start/end](start + 1, end);
}

void Finish(int n, int end)
{
	// Deliberately empty
}

int main () 
{
	functionPointers[0] = PrintStartToEnd;
	functionPointers[1] = Finish;

	cout << "Enter a number: ";
	int n;
	cin >> n;

	PrintStartToEnd(0, n);
}
