/******************************************************************************
* Name: Donna Gabai
* NetID: dgabai
* Precept: P99
*
* Fall 2014, Programming Exam 1, Collatz Conjecture:
* This program plots the length of the first N Collatz sequences, scaled
* to fit within the unit square.
*
* Dependencies: StdDraw.java, F14Part1.java, F14Part2.java
****************************************************************************/
public class F14Part3 {
public static void main(String[] args) {
int N = Integer.parseInt(args[0]);
// find the max length of the first N collatz sequences
int max = F14Part2.maxLength(N);
// set pen radius based on N
if (N < 100) StdDraw.setPenRadius(.05);
else StdDraw.setPenRadius(.01);
// plot length of each collatz sequence scaled to fit the unit square
for (int i = 1; i <= N; i++) {
double x = (double) i / N;
double y = (double) F14Part1.seqLength(i) / max;
StdDraw.point(x, y);
}
}
}