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 ...
随机推荐
- OC字符串常用函数
创建一个字符串对象: NSstring * str1 = @"hello"; NSString * str = [[NSString alloc]initWithString:@& ...
- nyoj 70 阶乘因式分解(二)
点击打开链接 阶乘因式分解(二) 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 给定两个数n,m,其中m是一个素数. 将n(0<=n<=2^31)的阶乘分解 ...
- HappyNum
/*Write an algorithm to determine if a number is "happy". A happy number is a number defin ...
- BC水题--The Factor(质因分解)
网址:http://acm.hdu.edu.cn/showproblem.php?pid=5428 roblem Description There is a sequence of n positi ...
- springMVC3 ckeditor3.6 图片上传 JS回调
一.引入js文件 <script type="text/javascript" src="<%=base %>/resources/ckeditor/c ...
- js控制TR的显示隐藏
在很多现实的场景中,有的文本框我们希望在选择“是”的按钮之后才出现,这就需要js控制TR的隐藏和显示,如何控制,本文为大家揭晓 下文分享的一段代码:选择是的按钮就显示身高和体重的文本框的代码.注意:r ...
- HTTP 500 的解决方案
我们首先要确定IIS权限的问题,如下所示: 身份验证的具体项: 身份验证的基本设置: 注意:如果不需要Form验证的情况下,那么把Form身份验证禁止掉,否则会出现在每一次请求的过程中都要有一个默认的 ...
- unique踢出相同元素
unique函数的功能是:去除相邻的重复元素(只保留一个). 函数参数:unique(first,last,compare); //first为容器的首迭代器,last为容器的末迭代器,compare ...
- hough变换
//c.h typedef unsigned char BYTE;typedef unsigned short WORD;typedef unsigned int DWORD;typedef long ...
- mysql创建远程用户
grant all privileges on *.* to myuser@"%" identified by 'password'; 用root用户登陆,然后: grant al ...