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 ...
随机推荐
- mysql事务与mysql储存引擎
事务概念及存储引擎 1.0 为何要事务? 先来看一个场景,银行转账汇款: 李彦宏和周鸿祎天天打架,现在让李彦宏给周鸿祎转款1000 元 设计如下表 account表 编号(id)用户名(user)金额 ...
- Ubuntu打开终端和设置root密码(转载)
From:http://blog.csdn.net/xhhjin/article/details/6328752 http://www.linuxsir.org/bbs/thread318516.ht ...
- 在linux下通过sh运行java程序
1.导出jar包放在目录下,如/home 2.通过vi创建sh文件如:test.sh,内容如:java -jar test1.jar com.wzh.test.test & 3.运行命令:sh ...
- sql执行返回值存储
List<Map> list = SqlRunner.queryMapList(sql); if(list != null && !list.isEmpty()){ Has ...
- PS 查看选定图层的高宽
1. 选中图层,然后按键盘"Ctrl+T(菜单中点编辑->自由变换)",然后上面工具条会出现调整比率,宽W:100% H:100%,然后在100%的位置点鼠标右键,选择 ...
- HDU 5521 [图论][最短路][建图灵感]
/* 思前想后 还是决定坚持写博客吧... 题意: n个点,m个集合.每个集合里边的点是联通的且任意两点之间有一条dis[i]的边(每个集合一个dis[i]) 求同时从第1个点和第n个点出发的两个人相 ...
- 4.1.1 A - Calendar(简单线性表)(日期查找)(数组应用)
Description A calendar is a system for measuring time, from hours and minutes, to months and days, a ...
- 修复:"Failed to start Load Kernel Modules"
使用非默认内核而出现的错误. [zsj@arch ~]$ systemctl --state=failed UNIT LOAD ACTIVE SUB DESCRIPTION● systemd-modu ...
- Arch Linux 休眠到文件
创建文件: # fallocate -l 4G /swapfile # chmod 600 /swapfile # mkswap /swapfile# swapon /swapfile 编辑/etc/ ...
- mfc 数据库显示到editcontrol控件问题
http://bbs.csdn.net/topics/390601634 CString CMyDB::VariantToString(const _variant_t &var) { ...