COS 226 Programming Assignment 8 - Checklist


Checklist 8: Factoring.

The following is a checklist which provides a summary of the assignment. This is meant only as a supplement; please read the original assignment description.

  • Frequently Asked Questions
  • Requirements
  • Advice

  • Frequently Asked Questions:
    (This is the only part of this checklist which will change during the week.)

    [Michael 4/16] WARNING: BigNum_rem(x,y) will crash if you call it when y=0. So our advice is not to ask for the remainder of a number when divided by zero. (We would offer to fix BigNum_rem to produce a nicer error message, but C also crashes if you try to evaluate (x%y) when y=0.)

    [Michael 4/13] Programming Platforms: The bignum.o and libgmp.a files which we are providing you for this assignment depend very much on what language you are using and on the architecture type of the machine you are using. The default files we have provided are for those programming in C, running on a Sun machine with solaris (such as the arizona machines).
    We will be as helpful as possible in providing similar versions of these files for any other environment you are using. Of course we cannot make any promises for the promptness of meeting requests, so please do not expect to mail us Sunday afternoon and have new files installed.
    In this regard, for those programming in C++ on the Sun machines, files have now been added in the /u/cs226/prog8_files/C++/SunOS/ directory. Any other architectures we add will be placed somewhere in the prog8_files directory.

    [Michael 4/13] The values of c and x0 are to be chosen independently. (the fact that our one example happen to have c=x0 should be viewed as a coincidence)

    [Michael 4/12] Please notice that most of the arithmetic functions in the ADT definitions of bignum.h return a new BigNum object which you are responsible for freeing when done. At first, you can probably get away with never freeing them and just leaving the wasted space sitting around, but as you try to factor larger and larger numbers, all of this space usage may haunt you.

    [Michael 4/11] There is no need to copy the files bignum.o and libgmp.a into your own directory (this is a waste of space). Simply compile with a command such as
    cc yourcode.c ~cs226/prog8_files/bignum.o ~cs226/prog8_files/libgmp.a
    (or else use symbolic links if you know how).

    [Michael 4/9] There were (originally) two typos in the assignment. The correct function to iterate is f(x)=(x*x+c) (mod N). Also, Euclid's algorithm is based on recursively finding the gcd of b and a%b.

    [Michael 4/8] For those working in Java, there is a builtin library BigInt which can handle multiple precision integer arithmetic.


    Due Date: Sunday, April 18
    Requirements:
  • Input Format: Your program should take N as the first command line argument so that we can run your program by typing a.out 42037, for example.
  • Output Format: The output for your program should include the following:
  • A line N=x*y where x and y are values determined by your program. (if no factors were found, simply output N=N*1)
  • Printout the starting values x0 and c which were used.
  • Printout the number of times the main loop of Pollard's method is executed.
  • Whenever N<1000, your program should printout a verbose table such as the one given in the original assignment description.
  • readme: Your readme file for this program should contain the following:
  • Give factors for all test values of N which we suggested that you were able to factor.
  • Include a discussion of the number of iterations of Pollard's main loop which you think are required, in general.
  • Feel free to include any other discussion of experiments you did for other huge integers.

  • Advice:
  • Remember, Pollard's rho method is not guaranteed to find factors of a composite N for every choice of x0 and c. For this reason it is important that you choose x0 and c at random, and that each run of your program is based on a different random choice. The checklist for program 6 discussed a similar issue.
    Of course, for debugging, it will be quite useful to bypass the random choices and set your own starting values (using extra command line arguments is most convenient).
  • Make sure you understand the definition for iterating a function i times.

  • cos226 Class Page
    wass@cs.princeton.edu
    Last modified: April 16, 1999