欧拉项目第五题 Smallest multiple
2016-03-09 11:12
429 查看
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly
divisible by all of the numbers from 1 to 20?
求能整除1-20的最小数。
求公倍数运用了辗转相除法,这玩意我也忘了...
What is the smallest positive number that is evenly
divisible by all of the numbers from 1 to 20?
求能整除1-20的最小数。
public static void main(String[] args) { int a1 =2; int t =2; for(;a1<20;a1++){ t = minMultiple(a1,t); } System.out.println(t); } //求最小公倍数 static int minMultiple(int a, int b) { int r = a, s = a, t = b; if (a < b) { r = a; a = b; b = r; } while (r != 0) { r = a % b; a = b; b = r; } return s * t / a; }这是循环处理,一个一个求最小公倍数运算的.
求公倍数运用了辗转相除法,这玩意我也忘了...
相关文章推荐
- Servlet3.0---异步支持
- 使用C#和.NET 4编写的并行应用程序“多核并发编程的规则”
- java.net.ConnectException: Connection refused
- 【OpenStack】OpenStack系列14之Dashboard定制开发
- jQuery实时刷新显示数据
- JS中常用正则表达式整理
- TCP/IP详解学习笔记
- 正确理解 ThreadLocal 的原理与应用场景
- Linux环境编程
- GCD 用法查询
- **在布局文件中设置Button的点击事件,代码中方法要传入View的原因分析**
- python 上传下载文件
- 学习进度条
- 学习进度条
- Android - 事件传递机制
- python真的还蛮可爱的(*^__^*)
- ateObjectsUsingBlock 、for 、for(... in ...) 的区别 & 性能测试 for VS for(... in ...)
- UE4-ServerTarget模板
- Emacs快捷键总结
- 竖线 横线