Problem 16

This is the archived version of this course from the Spring 2013 semester. You might find something more recent by visitning my teaching page.

Random using dev random

Due: February 1
Points: 4

Write a program in Java, C++, or python3 that takes a single integer n as a command-line argument and produces a stream of 500 random numbers, one per line, in the range of 1 up to n.

Your program should produce these numbers by reading data from the /dev/random device in Linux. Take care! This "file" produces random bytes of data, not characters. So if you try to read from it in the regular ways, it will not work the way you expect. Instead you have to use "raw" or "binary" input methods such as read in C++.

For the full 4 points, you need to handle n as large as \(2^{31}-1\).

Submit your program according to the instructions on the submit page.