Question: Write a Forth source file collcount.fs as follows. Be sure to follow the Coding Standards. Your file should define the word collcount. Word collcount should
Write a Forth source file collcount.fs as follows. Be sure to follow the Coding Standards.
Your file should define the word collcount.
Word collcount should have stack effect (n -- c), where n is a positive integer, and c is the number of iterations of the Collatz function required to take n to 1.
Your code does not need to do any type checking or other error checking.
Here is a sample Gforth session using collcount.
[Interactive Forth]
include collcount.fs ok 1 collcount . 0 ok 7 collcount . 16 ok 9 collcount 3 collcount . . 7 19 ok
Your file may define any other symbols you wish.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
