Skip to content

Instantly share code, notes, and snippets.

@vijaykiran
Created November 30, 2011 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijaykiran/1408604 to your computer and use it in GitHub Desktop.
Save vijaykiran/1408604 to your computer and use it in GitHub Desktop.
(defn average-b
"Calculates average value of any numbers"
[]
(println "How many numbers ?")
(let [n (Integer/parseInt (read-line))]
(loop [m 1 sum 0]
(if (> m n)
(/ sum n)
(do
(println (str "Enter number " m ": "))
(recur (inc m) (+ sum (Double/parseDouble (read-line)))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment