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 |
#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 评论:
发表评论