P32 (**) Determine the greatest common divisor of two positive integer numbers.
来源:互联网 发布:超级卡司是真是假 知乎 编辑:程序博客网 时间:2024/06/11 11:01
问题描述
sash> (gcd 36 63) -> 9
用欧几里得算法解决。
解法
最大公约数运算在数论上比较常见,标准库有同名的函数。
题目要求a和b是正数,下面的实现不能用于负数的情况。因
故只要简单处理一下参数就可以适用于负数的情况
(define gcd (lambda (a b) (if (zero? b) a (gcd b (floor-remainder a b)))))
1 0
- P32 (**) Determine the greatest common divisor of two positive integer numbers.
- Greatest Common Divisor(GCD) of Two Numbers
- The Greatest Common Divisor
- the greatest common divisor
- [计算最大公因子]Finding the greatest common divisor (gcd) of 2 numbers
- Calculate the Greatest Commom Divisor (GCD) and Lowest Common Multiple (LCP) of Two Integers
- P33 (*) Determine whether two positive integer numbers are coprime.
- Greatest Greatest Common Divisor
- The greatest common divisor gcd(最大公约数)
- given two unordered list find the greatest common integer
- Greatest Greatest Common Divisor HD5207
- Greatest common divisor
- GCD (Greatest Common Divisor)
- Solving Greatest Common Divisor
- 最大公约数Greatest Common Divisor
- The middle-school procedure for Greatest-Common-Divisor
- 最大公约数(greatest common divisor)算法
- 最大公约数(Greatest Common Divisor)
- 一些大牛技术历程及经验积累
- SpringMVC介绍之约定优于配置
- [pat]1038. Recover the Smallest Number (30)
- 2016年计算机视觉和图像处理相关的国际会议一览表
- 一文搞懂HMM(隐马尔可夫模型)
- P32 (**) Determine the greatest common divisor of two positive integer numbers.
- NSAttributedString
- PAT-A1059. Prime Factors (25(素数)
- MySQL数据库表的基本操作
- struts2学习笔记------接受请求参数
- nyoj 171 聪明的kk(数塔演变)
- Redhat如何查看和修改IP地址
- 1104. Sum of Number Segments (20)
- java中四种引用类型