{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ps3sols

ps3sols - Massachusetts Institute of Technology 6.857...

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

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. Specifically, 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- finding algorithm for large values of k , and also caused some false alarms during grading. Fortunately, the bug is fixed 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 find many values of b that form a “prime pair” with a (i.e., both a b and b a are prime). For 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. For 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 fixed 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 significant performance advantages over code written in Java. Groups that wrote their programs in C typically were able to find triangles for larger values of k than groups who used Java, using comparable algorithms. For 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-finder, in Java. With it, we were able to find 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 find a prime triangle for k = 140 in about 6 hours. The code can be downloaded from the 6.857 website. 1 /** 2 A reasonably efficient prime triangle finder, written for Problem 3-1 3 of 6.857, Fall 2003.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

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
Ask a homework question - tutors are online