Created
November 30, 2010 19:01
-
-
Save raek/722184 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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