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==)
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=;
for(i=; i<=N; i++)
{
s=lcm(s,i);
}
printf("%d\n",s);
} int main()
{
solve();
return ;
}
Answer:
232792560

(Problem 5)Smallest multiple的更多相关文章

  1. (Problem 46)Goldbach's other conjecture

    It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a ...

  2. (Problem 73)Counting fractions in a range

    Consider the fraction, n/d, where n and d are positive integers. If nd and HCF(n,d)=1, it is called ...

  3. (Problem 42)Coded triangle numbers

    The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangl ...

  4. (Problem 41)Pandigital prime

    We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly o ...

  5. (Problem 70)Totient permutation

    Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number ...

  6. (Problem 74)Digit factorial chains

    The number 145 is well known for the property that the sum of the factorial of its digits is equal t ...

  7. (Problem 72)Counting fractions

    Consider the fraction, n/d, where n and d are positive integers. If nd and HCF(n,d)=1, it is called ...

  8. (Problem 53)Combinatoric selections

    There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 2 ...

  9. (Problem 49)Prime permutations

    The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual ...

随机推荐

  1. 电脑bios到底是什么?

    没有哪个玩电脑的人不知道电脑bios,但是真正能明白bios是什么的?身边却没几个,甚至大多数电脑维修站的人员对bios也不够详细了解.一般人不去关心bios是因为它离我们的电脑真正使用仍有一段距离. ...

  2. 转:在控制台中调试AngularJS应用

    在控制台中调试AngularJS应用 在创建AngularJS应用时,一个很棘手的问题是如何在Chrome,Firefox,以及IE的JavaScript控制台中访问深藏在应用中的数据和服务.本文将会 ...

  3. 使用Boost.Asio编写通信程序

    摘要:本文通过形像而活泼的语言简单地介绍了Boost::asio库的使用,作为asio的一个入门介绍是非常合适的,可以给人一种新鲜的感觉,同时也能让体验到asio的主要内容. Boost.Asio是一 ...

  4. [uva 11762]Race to 1[概率DP]

    引用自:http://hi.baidu.com/aekdycoin/item/be20a91bb6cc3213e3f986d3,有改动 题意: 已知D, 每次从[1,D] 内的所有素数中选择一个Ni, ...

  5. 使用mongodb存取lbs数据

    1,在mongodb中创建lbs_db数据库,collection名称lbs_info,要使用lbs查询功能,需要对二维数据列建立索引 db.lbs_info.ensureIndex( { locs ...

  6. java软件工程师成长过程的学习

    第一阶段:Java基础,包括java语法,面向对象特征,常见API,集合框架: *第二阶段:java界面编程,包括AWT,事件机制,SWING,这个部分也可以跳过,用的时候再看都能来及: *第三阶段: ...

  7. js数组练习

    //查找数组对象中 age 大于 18 对象 function filterAdult(arr) { return arr.filter(function(item, index, array) { ...

  8. JQuery的stop()属性

    $(function(){ $('#input1').hover( function(){ $('.div1').stop() .animate({left:) .animate({top:); } ...

  9. VMWare11虚拟机安装OSX10.9系统资源下载及问题解决

    适配VMware11的MacOSX补丁: http://pan.baidu.com/s/1bnqgtDd 使用方法:将补丁解压到一个完全没有中文的目录下,以管理员方式运行目录中的win-install ...

  10. 操作数组的工具类Arrays

    Java提供的Arrays类里包含一些static修饰的方法可以直接操作数组. int binarySearch(type[] a, type key)使用二分法查询key元素值在a数组中出现的索引, ...