no mul->shl as it confuses address matching
[qbe.git] / minic / test / collatz.c
blob1d8a96c0cd833ff9427b6681c321ca3ae10d7f35
1 void *malloc();
3 main()
5 int n;
6 int nv;
7 int c;
8 int cmax;
9 int *mem;
11 mem = malloc(sizeof(int) * 4000);
13 cmax = 0;
14 for (nv = 1; nv < 1000; nv++) {
15 n = nv;
16 c = 0;
17 while (n != 1) {
18 if (n < nv) {
19 c = c + mem[n];
20 break;
22 if (n & 1)
23 n = 3*n + 1;
24 else
25 n = n / 2;
26 c++;
28 mem[nv] = c;
29 if (c > cmax)
30 cmax = c;
32 printf("should print 178: %d\n", cmax);