replaces rand() with random() and seeds with /dev/random instead of time

random() is better than rand() in many ways

seeding with /dev/random is important in case you want to run this on some cluster and all the nodes start it simultaneously (and thus compute the same thing, wasting lots of time).