#!/usr/bin/env python # Copyright 2005 Daniel Cer (daniel.cer@cs.colorado.edu) # # This work is licensed under the Creative Commons Attribution-NonCommercial- # ShareAlike License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc-sa/2.5/ or send a letter to # Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, # 94105, USA. import sys randu_state=1 def randu(): global randu_state; randu_state=(65539*randu_state) % 2**31 return randu_state if len(sys.argv) != 2: print >>sys.stderr,"Usage:\n\t%s (number of values to generate*)"%sys.argv[0] print >>sys.stderr,"\n* '0' -> unlimited"; sys.exit(-1) max_iters = int(sys.argv[1]) if max_iters < 0: print >>sys.stderr,"Error: parameter must be non-negative"; sys.exit(-1) if max_iters==0: while(true): print randu() else: for i in xrange(0,max_iters): print randu()