All pastes #575475 Raw Edit

Miscellany

public c v1 · immutable
·published 2007-06-19 01:47 UTC
rendered paste body
#include <stdio.h>int main() {	unsigned long lower, upper, orig_upper, orig_lower, current, test;	int max, cycle;	while (scanf("%d %d\n", &lower, &upper) == 2) {		orig_upper = upper;		orig_lower = lower;		if (lower > upper) {			lower = orig_upper;			upper = orig_lower;		}		max = 0;		for (current = lower; current <= upper; current++) {			test = current;			for (cycle = 1; test > 1; cycle++)				test = (test%2) ? test*3+1 : test/2;			if (cycle > max)				max = cycle;		}		printf("%d %d %d\n", orig_lower, orig_upper, max);	}	return 0;}