ps3sols - Massachusetts Institute of Technology 6.857:...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Massachusetts Institute of Technology Handout 12 6.857: Network and Computer Security October 7, 2003 Professor Ronald L. Rivest Problem Set 3 Solutions Problem 3-1. Prime Triangles. TA Notes: It is a little-known fact (to us, anyway) that the Java 1.4.1 class library contains a bug in part of its primality tester. SpeciFcally, the Lucas-Lehmer test is implemented incorrectly, and sometimes reports that certain large numbers are composite when they are actually prime 1 . This slowed down our own triangle- Fnding algorithm for large values of k , and also caused some false alarms during grading. ±ortunately, the bug is Fxed in version 1.4.2. Most good solutions (and our own, as well) used the following general framework: pick a value a (it helps if a is prime, so that it’s relatively prime to all b and c ), then Fnd many values of b that form a “prime pair” with a (i.e., both a b and b a are prime). ±or each newly-found value of b , see if it forms a prime pair with any previously-found value c ; if so, return ( a, b, c ) as a prime triangle. ±or a fast implementation of the above algorithm, there are several optimizations that can be used before employing full Miller-Rabin tests: the Sieve of Eratosthenes, small prime divisor tests, and greatest common divisor tests. While this strategy works very well, the search time for k -digit prime triangles seems to vary wildly, even for Fxed k . This is probably due to the fact that some a values can work in many triangles, while others cannot belong to any at all ( a = 73 is one example for k = 2). The running time, then, dramatically depends upon how lucky we are at choosing a good initial value of a . It also seems that code written in C (using the GMP toolkit, for example) still has signiFcant performance advantages over code written in Java. Groups that wrote their programs in C typically were able to Fnd triangles for larger values of k than groups who used Java, using comparable algorithms. ±or grading, we reserved the top scores (9s and 10s) for groups who described good algorithms and found triangles for k = 40 or higher. A decent algorithm and a value of k = 20 or higher typically earned 7 to 8 points. Using an algorithm similar to the one below (but written in C), the group of Alexandros Kyriakides, Saad Shakshir, and Ioannis Tsoukalidis found a prime triangle for k = 140 . The following is our (heavily-commented) implementation of a prime triangle-Fnder, in Java. With it, we were able to Fnd a prime triangle for k = 100 in about 30 minutes on an Athlon 1.4 GHz machine running Debian Linux. On average and on the same hardware, we are able to Fnd a prime triangle for k = 140 in about 6 hours. The code can be downloaded from the 6.857 website. 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/28/2009 for the course CS 6.857 taught by Professor Rivest during the Spring '03 term at MIT.

Page1 / 9

ps3sols - Massachusetts Institute of Technology 6.857:...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online