Question:
2520 is the smallest number divisible by 1 to 10. Write a C program to find the smallest number divisible by 1 to 20.
Program:
#include <stdio.h>
int main()
{
int n,c,j;
for(n=2520; ;n++)
{
c=0;
for(j=1;j<=20;j++)
{
if(n%j
!= 0)
{
c=1;
break;
}
}
if(c==0)
{
printf("the
smallest number divisible by 1 to 20 = %d",n);
break;
}
}
}
Output:
No comments:
Post a Comment