Artifact 2de93bf6e13bc1e2f423d2e7b8202834efeb9156ee3270beabcad9c84dd4ecf2:
- File src/cc8/examples/fib.c — part of check-in [9c75595f59] at 2020-10-27 16:02:01 on branch trunk — Merged CC8 "V2.0" down to trunk. (user: tangent size: 433) [more...]
/* Print the Fibonacci series. For OS/8 native compiler or cc8 */ /* Invoke with .EXE CCR and enter this filename */ /* Note use of recursion */ int fib(n) { if (n < 2) return n; else return fib(n-1)+fib(n-2); } int main() { int i,rsl; i=1; while (1) { rsl=fib(i); if (rsl<0) { printf("Overflow at #%d = %u\r\n",i,rsl); break; } printf("Fib #%2d = %d\r\n",i,rsl); i++; } }