不用别人认可也不用别人理解,尽情去做自己认为应该做的事……

2009年5月6日星期三

Problem 5--(c)

Problem 5

30 November 2001

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 number that is evenly divisible by all of the numbers from 1 to 20?


Answer:
232792560
code:
#include
int main(void)
{
long int max=2520;
int i;
while(1)
{
for(i=1;i<=20;i++)
{
if(max%i!=0)
break;
}
if(i==21&&max%20==0)
{
printf("%ld\n",max);
break;
}
max+=1;
}
return 0;

0 评论: