Files
bux-lang/vendor/qbe/minic/test/collatz.c
T
dimgigov eb8179b6d0 fix(qbe): any-child terminator check in QBE_IsTerminator for hBlock — QBE SSA now fully valid
- QBE_IsTerminator(hBlock) checks ALL children, not just last
- Removed legacy c_backend.bux and nim_backend.bux from _selfhost/src/
- QBE self-hosting QBE phase: PASSES (SSA valid, assembled to .s)
- Remaining: linker errors from missing String_Eq/StringBuilder in runtime
2026-06-02 13:56:12 +03:00

34 lines
401 B
C

void *malloc();
main()
{
int n;
int nv;
int c;
int cmax;
int *mem;
mem = malloc(sizeof(int) * 4000);
cmax = 0;
for (nv = 1; nv < 1000; nv++) {
n = nv;
c = 0;
while (n != 1) {
if (n < nv) {
c = c + mem[n];
break;
}
if (n & 1)
n = 3*n + 1;
else
n = n / 2;
c++;
}
mem[nv] = c;
if (c > cmax)
cmax = c;
}
printf("should print 178: %d\n", cmax);
}