问题描述:
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
(ns euler-problem-3.core)
(defn largest-prime-factor
[number]
(loop
[current-num number,n 2,lpf 2]
(if (>= lpf current-num)
lpf
(if (zero? (rem current-num n))
(recur (/ current-num n) n n)
(recur current-num (inc n) lpf)))))
(largest-prime-factor 13195)
(largest-prime-factor 600851475143)
"Elapsed time: 4.15835 msecs"
结果:6857
right!
递归三参数:第一个参数用来保存整除的商,第二个参数用来保存当前的除数,第三个参数用来保存最大的质因素
分享到:
相关推荐
该存储库是使用Clojure解决Euler问题的支架。 它以有组织的结构生成规格和解决方案存根,从而使生活稍微好一些。 安装 如果尚未安装,则将其添加到您的路径中。 签出这个项目: $ git clone git@github....
Clojure骇客解决了Euler项目的问题。 目的是用惯用的Clojure编写功能解决方案。 用法 大多数解决方案都是完整的,并且完全独立地包含在具有“解决”功能的唯一名称空间中。 有些正在“进行中”。 执照 版权所有:...
欧拉计划 问题1-2、4、6、8-10、12、14、21、24-26、32、34、36、39、41、46、49、52、55-58、62、65的Clojure解决方案70-74、87、92、97、124、173-174、179、187、214运行解决方案使用以下命令行运行解决方案: ...
Clojure's clean, careful design lets you write programs that get right to the essence of a problem, without a lot of clutter and ceremony. Clojure is Lisp reloaded. Clojure has the power inherent in...
欧拉解决Clojure中的Euler项目问题的方法。 持续的爱好。执照版权所有:copyright:2012-2015 Dave Yarwood 在Eclipse Public License 1.0版下分发。
Clear, practical Clojure for the professional programmer Professional Clojure is the experienced developer's guide to functional programming using the Clojure language. Designed specifically to meet ...
在今后的软件设计中无论使用Clojure语言,还是坚持使用Java语言,Clojure语言都将与java做比较,哪种是设计软件的最佳方式。 Clojure语言是一个JVM(包括Groovy,Jython和JRuby等语言)的新语言,它提供了活力,...
Clojure is an opinionated language—it doesn’t try to cover all paradigms or provide every checklist bullet-point feature. Instead it provides the features needed to solve all kinds of real-world ...
Practical Clojure Clojure语言书籍
clojure clojure clojureclojure clojure
【1】[Clojure编程乐趣]...【3】Clojure Cookbook.pdf 【4】Clojure Data Analysis Cookbook.pdf 【5】clojure Hand book(中文).pdf 【6】Clojure in Action.pdf 【7】clojure in small pieces.pdf 以上7本书的电子版
函数式编程之Clojure.pdf [2015] Clojure for the Brave and True - Learn the Ultimate Language and Become a Better Programmer.(Daniel Higginbotham).[1593275919].rar [2015] Clojure Web Development ...
主要特性:从 Java 中保护你的 Clojure 程序,进行安全的互操作,正确的使用外部 Java 库。Typed Clojure 支持关键字映射的使用,类型检测器中包含有用的映射操作,包括关键字查找,添加或者移除关键字,合并映射...
Programming Clojure(3rd) 英文azw3 第3版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
[2013] Functional Programming Patterns in Scala and Clojure - Write Lean Programs for the JVM.(Michael Bevilacqua-Linn).[1937785475].pdf+epub.rar [2014] Clojure Cookbook - Recipes for Functional ...
Clojure编程乐趣和clojure_programming.pdf两本书
tools.analyzer, 用于Clojure代码的分析器,用Clojure编写,并在EDN中生成 AST tools.analyzer主机无关Clojure代码的分析器,用Clojure编写,并在EDN中生成 AST 。我在 2015年12月的ClojureX上讨论了 tools.analyzer...
简单易学的一本书,让你轻松入门clojure,此书比较薄,每个点都要细细看,要不然几句话就不看就错过了重点知识
Chapter 3. Parallelization Using Reducers Chapter 4. Metaprogramming with Macros Chapter 5. Composing Transducers Chapter 6. Exploring Category Theory Chapter 7. Programming with Logic Chapter 8. ...