Created
September 13, 2013 20:21
-
-
Save sirpengi/6555581 to your computer and use it in GitHub Desktop.
diagonal sum in clojure
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
(ns diagonal-sum) | |
(defn ds-step [[v prev step]] | |
[(+ v (* 4 prev) (* 10 step)) (+ prev (* 4 step)) (+ step 2)]) | |
(defn ds-seq [] | |
(map first (iterate ds-step [1 1 2]))) | |
(println (take 10 (ds-seq))) | |
;(1 25 101 261 537 961 1565 2381 3441 4777) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment