(Problem 5)Smallest multiple
来源:互联网 发布:淘宝宝贝视频怎么制作 编辑:程序博客网 时间:2024/05/29 13:17
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?
#include <stdio.h>#include <string.h>#include <ctype.h>#include <math.h> #define N 20 int gcd(int a, int b){ if(b==0) return a; else return gcd(b,a%b);} int lcm(int a, int b){ return a/(gcd(a,b))*b;} void solve(){ int i,s=2; for(i=3; i<=N; i++) { s=lcm(s,i); } printf("%d\n",s);} int main(){ solve(); return 0;}
Answer:
232792560- (Problem 5)Smallest multiple
- Problem 5:Smallest multiple
- Problem 5 Smallest multiple
- Problem 5 Smallest multiple(LCM)
- 【Project Euler】【Problem 5】Smallest multiple
- project euler problem 5:Smallest multiple
- Project Euler Problem 5: Smallest multiple
- projecteuler---->problem=5----Smallest multiple n个数求最小公倍数
- 欧拉计划(5) Smallest multiple
- PE 5 Smallest multiple
- 5 Smallest multiple - Project Eulder
- Smallest multiple
- Smallest Common Multiple
- Smallest Common Multiple
- Smallest Multiple by GoLang
- Smallest Common Multiple
- Project Euler 005 Smallest multiple
- Smallest multiple 求1-20的最小公倍数
- linux上iscsi工具部署详解&&分布式文件系统提供iscsi接口的简单方法
- C# 实现对XML文件的基本操作(创建xml文件,增、删、改、查 xml节点信息)
- POJ 2777 Count Color (线段树&位运算)
- Cannot make a static reference to the non-static method
- HDU 2059 龟兔赛跑
- (Problem 5)Smallest multiple
- jquery 定位元素几种方法
- 使用Java进行远程方法调用的几个方案及比较
- cocos2d-x根据点击的位置来拖动精灵
- 为学Android,我看了这些书
- delphi控件安装与删除
- iOS开发:接触IOS的第一个组件UILabel (常用属性)
- JSON之解析通过TouchJSON\SBJSON\JSONKit\NSJSONSeriliz...
- (Problem 7)10001st prime