Skip to content

Instantly share code, notes, and snippets.

@raek
Created November 30, 2010 19:01
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 raek/722184 to your computer and use it in GitHub Desktop.
Save raek/722184 to your computer and use it in GitHub Desktop.
(defn print-pyramid [n]
(loop [i n, spaces (apply str (repeat (dec n) " ")), stars "*"]
(println (str spaces stars))
(when (> i 1)
(recur (dec i) (.substring spaces 1) (str stars "**")))))
;; user=> (print-pyramid 10)
;; *
;; ***
;; *****
;; *******
;; *********
;; ***********
;; *************
;; ***************
;; *****************
;; *******************
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment