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 ...
随机推荐
- Python & MapReduce
使用Python实现Hadoop MapReduce程序 原文请参考: http://blog.csdn.net/zhaoyl03/article/details/8657031/ 下面只是将mapp ...
- ubuntu 修改静态IP和DNS
1.修改配置文件/etc/network/interfacesroot@ubuntu:~# sudo vi /etc/network/interfaces 添加以下内容:auto eth0 ...
- win10安装软件被阻止后
以管理员身份运行CMD,然后在cmd里执行就可以了.
- springmvc 注解 RequestParam/RequestHeader/CookieValue
RequestParam注解: 示例: @RequestMapping("/testRequestParam") public String testRequestParam(@R ...
- delphi中使用spcomm来实现串口通讯(转载)
http://blog.sina.com.cn/s/blog_7880f98301010pi8.html 转自——飘雪的世界 最近两天一直在研究spcomm控件的使用,之前也是很不太明白,看了很多的例 ...
- 【转】SQL Server 查询表的记录数(3种方法,推荐第一种)
--SQL Server 查询表的记录数 --one: 使用系统表. SELECT object_name (i.id) TableName, rows as RowCnt FROM sysindex ...
- Hibernate注解:一对一主键关联
情形:两个表,my_site和my_site_company,通过主键site_id唯一关联.my_site的主键是自动增加,my_site_company的主键依赖于my_site. # # Sou ...
- freemarker中使用shiro标签
地址:https://github.com/jagregory/shiro-freemarker-tags下载该jar包 或者源代码文件复制到自己工程的lib下或者package中 如果使用spri ...
- Android设置不被系统设置改变的字体大小
原因 从4.0开始,系统设置中“显示”可以对字体大小进行配置,这会影响到TextView等控件中文字显示的大小. 解决方案 在自定义的Activity中重写getResources方法 @Overri ...
- Android中MenuInflater实例
我们知道,LayoutInflater是用来实例化整个布局文件,而MenuInflater是用来实例化Menu目录下的Menu布局文件的. 传统意义上的菜单定义需要Override Activity的 ...