Part 1a

  • Start by reading in the four parameters, and printing them to the screen.

  • Some students find the while loop easier to deal with than the for loop. So you can start by performing the iterates using a while loop. After you get this working, then redo it with a for loop.

  • Part 1b

  • Review the printf formatting options (especially King p. 34) to allocate 4 spaces for printing each integer.

  • Use a variable, say i to count the number of iterations. Print a newline character if i is a multiple of 20. Use the % operator to do this.

  • Part 2

  • Write the code for finding a point on the cycle. Consider using a do-while loop. Don't worry about computing the cycle length until you've done this.

  • Warning: the length of the cycle is not necessarily the same as the number of iterates until the fast and slow generators arrive at the same point. As described in the assignment, you need to go around the cycle one more time to compute its length.



  • Kevin Wayne