#!/usr/local/bin/guile \
-e main -s
!#

;;; $Id: random.guile,v 1.9 2001/07/31 16:38:37 doug Exp $
;;; http://www.bagley.org/~doug/shootout/

(use-modules (ice-9 format))

(define IM   139968)
(define IA     3877)
(define IC    29573)

(define LAST 42)
(define (gen_random max)
  (set! LAST (modulo (+ (* LAST IA) IC) IM))
  (/ (* max LAST) IM))

(define (main args)
  (let ((n (or (and (= (length args) 2) (string->;number (cadr args))) 1)))
    (let loop ((iter n))
      (if (>; iter 1)
      (begin
        (gen_random 100.0)
        (loop (- iter 1)))))
    (display (format "~,9F\n" (gen_random 100.0)))))