// $Id: random.java,v 1.10 2001/05/08 01:51:39 doug Exp $ // http://www.bagley.org/~doug/shootout/ import java.text.*; public class random { public static final long IM = 139968; public static final long IA = 3877; public static final long IC = 29573; public static void main(String args[]) { int N = Integer.parseInt(args[0]); NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(9); nf.setMinimumFractionDigits(9); nf.setGroupingUsed(false); double result = 0; while (N-- > 0) { result = gen_random(100); } System.out.println(nf.format(result)); } public static long last = 42; public static double gen_random(double max) { return( max * (last = (last * IA + IC) % IM) / IM ); } }