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. 闲来无事写写-Huffman树的生成过程

    前言:最近项目上一直没事干,感觉无聊到了极点,给自己找点事做,补一下大学没有完成的事情,写一个huffman算法Java版的,学校里面写过c语言的. 因为很久没搞数据结构和算法这方面了(现在搞Java ...

  2. 怪兽z主机豪华版 答问。

    我的淘宝店里,怪兽z主机标准版,分经济版本,标准版,豪华版,三个版本.这里给大家详细介绍一下豪华版的概况. 淘宝购买地址:http://item.taobao.com/item.htm?id=3818 ...

  3. VARCHAR2(N CHAR)与VARCHAR2(N)的区别[Oracle基础]

    转载: http://blog.itpub.net/24930246/viewspace-1064982 在数据库开发的时候,经常需要考虑存储空间的问题,当然很多时候我们并不需要去考虑一些细小的差别, ...

  4. inlay检验标准

    Inlay 检验标准 检验条件及要求 正常的 40W 日光灯下距离被检物 50cm,眼睛距离被检物 30cm,与被检物呈 45 度角,目视检 使用强光灯箱透视其内部结构 适用范围 Inlay 中料 检 ...

  5. poj 2001 Shortest Prefixes(字典树)

    题目链接:http://poj.org/problem?id=2001 思路分析: 在Trie结点中添加数据域childNum,表示以该字符串为前缀的字符数目: 在创建结点时,路径上的所有除叶子节点以 ...

  6. android下文件下载

    public static void downFile(final String url){ new Thread(){ public void run(){ FileOutputStream os= ...

  7. x0vncserver Fatal server error: no screens found

    I make a connection through SSH and  then I type: # x0vncserver --PasswordFile=/home/hello/.vnc/pass ...

  8. Android Material Design-Creating Apps with Material Design(用 Material Design设计App)-(零)

    转载请注明出处:http://blog.csdn.net/bbld_/article/details/40400031 翻译自:http://developer.android.com/trainin ...

  9. HttpModule、HttpHandler和Page的生命周期

    1.引言 2.两个处理步骤 2.1.创建ASP.NET环境 2.2.用触发的MHPM事件处理请求 3.什么事件中应该做什么 4.示例代码 5.深入ASP.NET页面事件 1.引言 这篇文章我们将试图理 ...

  10. js取整

    综述 js中经常会遇到取整问题,所以做了下总结.总的来说分为两个方面,直接取整(不考虑小数点后的部分)还是计算后取整(例如四舍五入,向上取整等). 一.直接取整 1.parseInt(number) ...