projecteuler Smallest multiple
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?
译:
2520是能被从1到10整除的最小整数,求出能被从1到20整除的最小数。
=======================================
第一次code:
public class Main
{
public static void main (String[] args)
{
System.out.println(sum(600000000));
}
public static int sum(int num)
{
int c=0;
for(int i=1;i<num;i++)
{
if(i % 1== 0 && i % 2 ==0
&& i % 3== 0 && i % 4 ==0
&& i % 5== 0 && i % 6 ==0
&& i % 7== 0 && i % 8 ==0
&& i % 9== 0 && i % 10 ==0
&& i % 11== 0 && i % 12 ==0
&& i % 13== 0 && i % 14 ==0
&& i % 15== 0 && i % 16 ==0
&& i % 17== 0 && i % 18 ==0
&& i % 19== 0 && i % 20 ==0
)
{
c=i;
break;
}
else
{
c=111;
}
}
return c;
}
}
projecteuler Smallest multiple的更多相关文章
- Smallest multiple
problem 5:Smallest multiple 题意:求最小的正数,使得其可以被1-20整除 代码如下: #ifndef PRO5_H_INCLUDED #define PRO5_H_INCL ...
- (Problem 5)Smallest multiple
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any rema ...
- Problem 5: Smallest multiple
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any rema ...
- Python练习题 033:Project Euler 005:最小公倍数
本题来自 Project Euler 第5题:https://projecteuler.net/problem=5 # Project Euler: Problem 5: Smallest multi ...
- Types of compression algorithms
http://www.html5rocks.com/en/tutorials/speed/img-compression/ Types of compression algorithms There ...
- PE 001~010
题意: 001(Multiples of 3 and 5):对小于1000的被3或5整除的数字求和. 002(Even Fibonacci numbers):斐波那契数列中小于等于4 000 000的 ...
- Alignment And Compiler Error C2719 字节对齐和编译错误C2719
Compiler Error C2719 'parameter': formal parameter with __declspec(align('#')) won't be aligned The ...
- Problem5-Project Euler
Smallest multiple 2520 is the smallest number that can be divided by each of the numbers from 1 to ...
- Project Euler Problem5
Smallest multiple Problem 5 2520 is the smallest number that can be divided by each of the numbers f ...
随机推荐
- 转载__Android开源项目(二)
http://www.csdn.net/article/1970-01-01/2815145 GitHub上的开源项目不胜枚举,通过这些项目,也能让开发者在应用开发过程中事半功倍,作为开发者的你,在用 ...
- rand srand
题外:先定义一个指针变量int *a; 再将整数b的地址赋给指针变量 a=&b ; 谨记指针变量a只是地址 *a相当于整数 之后*a 就可以表示 指向b了 也可以在定义的时候初始化 in ...
- js swipe 图片滑动控件实现 任意尺寸适用任意屏幕
http://www.swiper.com.cn/http://www.idangero.us/swiper/demos/ 解决问题点: 1.先得到图片真实的宽高, 根据真实宽高 等比例 2.调用的控 ...
- Eclipse UML插件Green UML、AmaterasUML
一.Green UML插件 1.查看Eclipse版本 查看当前电脑上安装的Eclipse版本(Help-About Eclipse Platform),是3.3.2版本的. 2.查看相应插件版本 然 ...
- 对 HTTP 304 的理解(转-并增加自己的测试)
作者:吴俊杰 性别:男 邮箱:sshroot@126.com 文章类型:原创 博客:http://www.cnblogs.com/voiphudong/ 转自: http://www.cnblogs. ...
- Jmeter Html 报告优化
转载自南风_real博客园:http://www.cnblogs.com/jaychang/p/5881525.html 但是最近在查阅相关资料时,发现基本都是重复一篇文章Jmeter使用笔记之htm ...
- Informix如何释放异常的锁资源
问题 在Informix数据库中,锁的使用和释放是自动完成的.但在某些异常情况下,当前台程序退出(正常或异常)后,相应在数据库中的会话没有终止,其占有的资源(主要是锁)没有被释放,影响了其他用户的使用 ...
- Zabbix监控和分布式部署实施方案
最近在研究Zabbix监控,由于机房分布在多个城市,因此采用zabbix proxy做为监控方案,在每 个节点部署zabbix proxy,由zabbix proxy收集agentd数据,然后将采集到 ...
- 查看mysql数据库引擎
1.查看支持的引擎 show engines; 2.查看当前引擎 show variables like '%storage_engine%'
- PreparedStatement批量(batch)插入数据
JDBC操作数据库的时候,需要一次性插入大量的数据的时候,如果每次只执行一条SQL语句,效率可能会比较低.这时可以使用batch操作,每次批量执行SQL语句,调高效率. public Boolean ...