#include "library.h" // this time we plot a graph of starting value against length // of sequence, to see if we can make out a pattern. We do see // the beginning of a pattern, but not enough of it int collatz(const int start) { int count = 0; int val = start; while (val != 1) { if (val % 2 == 0) val = val / 2; else val = val * 3 + 1; count = count + 1; } return count; } void main() { make_window(700, 600); set_pen_width(3); set_pen_color(color::red); int n = 1; while (n < 7000) { const double k = collatz(n); move_to(n, 600-k); draw_point(); n = n + 1; } }